Top 50 C# Interview Questions for Freshers (with Answers)
Codevity Admin · 10/25/2026
Step 30 of 31 · C# Interview Preparation for Beginners · Stage 6: Design, testing and interview readiness
Codevity Admin · 10/25/2026
These are the 50 questions freshers meet most often in C# and .NET interviews, grouped by topic. Each has a priority (High, Medium or Low, by how often it is asked) and a short answer you can say out loud. Answers assume modern .NET (8 or later). Start with the High priority questions.
High priority. C# is the programming language. .NET is the platform: runtime, base class library and tools. The CLR is the part of .NET that executes your code: it JIT-compiles IL to machine code, runs the garbage collector and enforces type safety. See C# vs .NET vs the CLR.
High priority. A value-type variable holds the data itself and is copied on assignment. A reference-type variable holds a reference to a heap object, and assignment copies the reference. A value type is stored where its variable lives: on the stack for a local, inside the object for a field. Reference-type objects always live on the heap.
High priority. Boxing converts a value type to object (or an interface) by allocating a heap object and copying the value. Unboxing casts it back and needs the exact type. The cost is an allocation plus garbage-collector work, so avoid it in hot paths by using generics.
High priority. A string never changes after creation, which makes it safe to share between threads, a reliable dictionary key and cacheable (interning). Every "modification" creates a new string, so building text in a loop with += is wasteful. StringBuilder appends into one mutable buffer. See strings in C#.
High priority. == is an operator picked by the compile-time type. For reference types it compares references unless overloaded (string overloads it). Equals() is virtual and picked by the run-time type. By default it compares references for classes and fields for structs, and types like string and record override it for content equality.
High priority. var is inferred at compile time and is still strongly typed. object is the base type of everything and needs casts. dynamic skips compile-time checking, and errors appear at run time.
High priority. is , a struct with a flag and a . It lets a value type represent "no value". Use or , because reading when is false throws .
High priority. is fixed at compile time, is implicitly static, and is limited to simple types such as numbers and strings. is assigned once at run time (in a declaration or constructor), can be any type and can differ per instance.
High priority. All pass by reference. requires an initialized variable that the method may read and change. needs no initial value, but the method must assign it before returning. passes a read-only reference, which avoids copying large structs.
High priority. Encapsulation (access modifiers, properties), inheritance (), polymorphism (/ and interfaces) and abstraction ( classes and interfaces). See OOP in C#.
High priority. Overloading is the same method name with different parameters, resolved at compile time. Overriding replaces a base method in a derived class, resolved at run time by the object's actual type.
High priority. allows a method to be replaced. replaces it and takes part in polymorphism. hides a base member: calls through a base-class reference still run the base version. Hiding is usually a mistake. See the virtual, override and new snippet.
High priority. An abstract class can hold state, constructors and implemented members, and a class can inherit only one. An interface is a contract with no instance state, and a class can implement many. Use an interface for a capability and an abstract class to share code.
High priority. Yes. It runs when a derived class is created and initializes shared state. It is normally , because the abstract class cannot be instantiated directly.
Medium priority. , , , , and . allows derived classes or code in the same assembly. allows derived classes and only within the same assembly.
Medium priority. A parameterless constructor with no access modifier that initializes static state. The runtime runs it once, automatically, before the first instance is created or any static member is accessed.
Low priority. No to both. A static class can contain only static members and is implicitly sealed.
Medium priority. Inheritance models "is-a" and ties a class to its base. Composition models "has-a" by holding other objects. Prefer composition: it is more flexible and easier to test.
High priority. An array has a fixed size. A grows and shrinks, and wraps an array that it reallocates (about doubling) when full. Both give O(1) index access.
High priority. It is a hash table. It calls on the key to pick a bucket, and uses to find the exact key within the bucket. Operations are O(1) on average. Key types need consistent and . See collections.
High priority. only iterates. adds , , and . adds index access and . Accept the least specific interface that does the job.
High priority. LINQ is a uniform way to query collections, databases and XML. Query syntax () reads like SQL. Method syntax () is what query syntax compiles to, and it has more operators. See LINQ in C#.
High priority. A query is only a recipe until you enumerate it with , , , and so on. It then runs against the data as it is at that moment. Enumerating twice runs it twice, so call once when you need to reuse the results.
High priority. throws when nothing matches. returns the default value ( for reference types, for ).
High priority. throws if there are zero or more than one match. returns the default for zero matches but still throws for more than one. Use them when more than one match would be a bug.
High priority. runs in memory using delegates. builds an expression tree that a provider (such as EF Core) translates, for example into SQL, so the filtering happens in the database. Calling or too early pulls everything into memory first.
High priority. Generics give compile-time type safety, remove casts, avoid boxing of value types and allow one implementation for many types. See generics.
Medium priority. Rules such as , , , a base class or an interface. They let the generic code use the members those types guarantee.
High priority. A delegate is a type-safe reference to a method with a specific signature. It lets you pass behaviour as a value and can hold several methods (multicast). A regular method is just code that you call directly.
High priority. Built-in generic delegates. returns a value. returns nothing. takes one argument and returns .
High priority. An event is a delegate field with restricted access: outside code can only subscribe and unsubscribe (, ), not invoke it or replace the handlers. See delegates, events and lambdas.
Medium priority. A static method in a static class whose first parameter has . It lets you call it as if it were an instance method of that type, without modifying the type.
Medium priority. Testing the shape of a value and extracting parts of it, using and expressions with type, relational (), logical (, , ), property and list patterns. See modern C#.
Medium priority. A struct is a value type. Use one for small, immutable, short-lived values (a point, a money amount). Avoid large or mutable structs, because copying them is costly and surprising.
High priority. A record is a type for data with generated value-based equality, a readable and non-destructive copying with . A class compares by reference by default.
Medium priority. allows a property to be set only during object creation, which gives immutability with initializer syntax. (C# 11) forces callers to set the property.
High priority. re-throws the original exception and keeps its stack trace. resets the stack trace to the current line and hides the real origin.
High priority. defines for releasing unmanaged resources. calls for you when the block (or scope) ends, even if an exception occurs: it compiles to a /. See exceptions and IDisposable.
High priority. The GC reclaims memory of unreachable objects. Gen 0 holds new objects and is collected often. Survivors move to Gen 1 and then Gen 2, which holds long-lived objects and is collected rarely. Objects of 85,000 bytes or more go on the large object heap. See garbage collection.
High priority. It reclaims their memory eventually, but it does not release the underlying handle promptly. Call , ideally with .
Medium priority. An object that stays reachable when it is no longer needed. A long-lived publisher holds references to subscribers' handlers, so a subscriber that never unsubscribes can never be collected. Static collections and unbounded caches cause the same problem.
High priority. Synchronous code blocks the calling thread until the work finishes. Asynchronous code frees the thread while it waits, typically for I/O, and continues when the result is ready. It is about not wasting threads, not about running things in parallel.
High priority. The compiler turns an method into a state machine. At an on an unfinished task, the method returns to its caller and registers a continuation that resumes it later. / itself does not create a thread. I/O waits use no thread at all, and is what queues CPU work to the thread pool. See async and await.
High priority. A is an operating-system thread that you create and manage, which is expensive. A represents an operation, usually scheduled on the shared thread pool, with results, exceptions, continuations and cancellation built in. Prefer .
High priority. The caller cannot await it or catch its exceptions, and an unhandled exception can crash the process. It is acceptable only for event handlers. Return instead.
Medium priority. returns a task you without blocking, and gives you the results. blocks the calling thread until all tasks finish, which wastes a thread and can deadlock.
High priority. Supplying a class's dependencies from outside, usually through the constructor and as interfaces, instead of creating them inside. It loosens coupling and makes code testable, because you can pass fakes. See DI, SOLID and unit testing.
High priority. Transient: a new instance on every request. Scoped: one instance per scope (per HTTP request in a web app). Singleton: one instance for the whole application. A service should not depend on one with a shorter lifetime.
High priority. Single responsibility (one reason to change), Open/closed (extend without modifying), Liskov substitution (derived types work wherever the base is expected), Interface segregation (small focused interfaces), Dependency inversion (depend on abstractions).
Medium priority. A unit test checks one small piece of behaviour quickly and in isolation. AAA structures it as Arrange (set up), Act (call the code) and Assert (check the result). Good tests are fast, deterministic and independent. See the xUnit test snippet.
Answer each question aloud in two or three sentences, then check yourself against the answer. For the High priority items, also write a small program that proves the point. Then take the C# interview quizzes in this collection.
int?Nullable<int>HasValueValue??GetValueOrDefault()ValueHasValueInvalidOperationExceptionconstreadonlyrefoutinclass B : Avirtualoverrideabstractvirtualvirtualoverridenewprotectedpublicprivateprotectedinternalprotected internalprivate protectedprotected internalprivate protectedList<T>GetHashCode()Equals()EqualsGetHashCodeIEnumerable<T>ICollection<T>CountAddRemoveContainsIList<T>Insertfrom x in xs where ... selectxs.Where(...).Select(...)foreachToList()Count()First()ToList()First()InvalidOperationExceptionFirstOrDefault()null0intSingle()SingleOrDefault()IEnumerable<T>IQueryable<T>ToList()AsEnumerable()where T : classstructnew()Func<..., TResult>Action<...>Predicate<T>bool+=-=thisisswitch< 18andornotToString()withinitrequiredthrow;throw ex;IDisposableDispose()usingDispose()tryfinallyDispose()usingasyncawaitasyncawaitTask.RunThreadTaskTaskTaskTask.WhenAllawaitTask.WaitAll