C# for placements: interview questions by topic
C# is the language of .NET, and it reaches placement rounds through companies that build on Microsoft's stack, from enterprise services to games made with Unity. It is examined the way campus tests examine any language, a few lines of code and 'what does this print?', and the questions gather where C# differs from Java, the language it is most often compared with: structs that copy themselves, == that compares string contents, methods that are not virtual unless you say so, and properties that look like fields.
Interviews then move to the parts of C# that have no direct Java counterpart: LINQ queries that run later than they appear to, records with value equality, nullable reference types, pattern matching, and the using statement that stands in for a destructor. Knowing which features arrived in which version, and why, shows that your C# is current.
The pages below take one topic each, with answers whose code was compiled and run on .NET 10, and one question exactly as the diagnostic asks it. The diagnostic draws from every C# topic in the bank and names the ones to read first.
C# topics, one page each
8 of the 8 C# topics in the bank have a page so far; the diagnostic draws from all 8.
- C# data types interview questions
C# types as interviews test them: value versus reference types, var and dynamic, nullable references, overflow, boxing and decimal for money.
- C# string interview questions
C# strings as interviews test them: immutability and StringBuilder, interning, interpolation, verbatim and raw literals, culture-safe comparison.
- C# classes and structs interview questions
C# classes and structs as interviews test them: class versus struct, records, properties, static classes, primary constructors and initialisers.
- C# inheritance and polymorphism interview questions
C# inheritance as interviews test it: virtual, override, new and sealed, abstract classes and interfaces, base calls, explicit interfaces and is.
- C# methods and parameters interview questions
C# methods as interviews test them: ref, out and in, how references are passed, optional and named arguments, params, extension and local functions.
- C# collections and generics interview questions
C# collections as interviews test them: List versus array, Dictionary lookups, HashSet, the collection interfaces, generic constraints and variance.
- C# LINQ and lambda interview questions
LINQ and lambdas as C# interviews test them: deferred execution, First versus Single, Select versus SelectMany, IQueryable, events and closures.
- C# exception handling interview questions
C# exceptions as interviews test them: try, catch and finally, rethrowing and wrapping, when filters, custom exceptions, using and finalizers.
One question, exactly as the diagnostic asks it
From the C# bank — 30 questions across 8 topics. The answer is marked because this one is public; in a sitting you choose first, then see why each option is right or wrong.
What does this C# code print?
var list = new List<int> { 1, 2, 3 }; var big = list.Where(x => x > 1); list.Add(4); Console.WriteLine(big.Count());
- 13correct
- 22
- 34
- 41
Where does not filter anything when it is called: it returns a query that remembers the source and the condition, and the filtering happens only when the query is enumerated, here by Count(). By then the list holds 1, 2, 3 and 4, so three elements pass: 3. 2 assumes Where filtered the list immediately, when it held 1, 2 and 3. 4 counts every element, ignoring the filter, and 1 counts only the added element. Calling ToList() or ToArray() runs a query at once and keeps the result; without it, every enumeration runs the query again against the current data.
Measure it
Reading the answers tells you what’s true. A diagnostic tells you what you get wrong.
10 C# questions across its topics, easy to hard, about fifteen minutes. You get a readiness figure with the arithmetic shown, the topics you missed named, and a practice set sized for today. Free: 1 diagnostic a month and 15 problems a day. No card.