Which statement about partial classes in C# is true?
Correct answer C. All parts must use the partial keyword and be in the same assembly and namespace
Topic / 95 questions
C# MCQs test the C Sharp language and the .NET platform it runs on, a common subject in software developer recruitment tests, computer science degrees and IT officer exams. Questions cover the CLR and garbage collection, types and conversions, operators, object-oriented programming, exceptions, delegates, generics, collections, LINQ and asynchronous code. Each answer includes a teaching explanation, and code-output questions use short single-line snippets.
Correct answer C. All parts must use the partial keyword and be in the same assembly and namespace
Correct answer B. An ArgumentException is thrown
Correct answer B. 0
Correct answer C. It returns one element of an iterator and resumes from that point on the next request
Correct answer D. When the caller first calls MoveNext, usually through foreach
Correct answer B. 3
Correct answer D. First() throws InvalidOperationException; FirstOrDefault() returns the type's default value
Correct answer A. from n in nums where n > 5 select n
Correct answer D. ToList
Correct answer A. int
Correct answer B. Callers cannot await them or catch their exceptions
Correct answer B. Task.WhenAll
Correct answer D. To attach declarative metadata to code elements that tools or reflection can read
Correct answer B. [Validated] or [ValidatedAttribute]
Correct answer C. It places every type in the file into that namespace without an extra pair of braces
Correct answer C. It suspends the method until the awaited task completes, without blocking the thread
Correct answer B. throw; keeps the original stack trace, while throw ex; resets it to the current point
Correct answer B. After the try block and any catch, whether or not an exception occurred, even after return
Correct answer A. this
Correct answer D. The property can be set only during object initialisation, then becomes read-only
The first part covers the .NET platform: the Common Language Runtime, CIL and JIT compilation, assemblies, the Base Class Library, managed code and how the garbage collector uses generations and the large object heap.
Language basics follow: value types versus reference types, sizes of built-in types, nullable value types, implicit and explicit conversions, boxing and unboxing, string immutability, var, dynamic, const and readonly, and operators such as integer division, remainder, null-conditional and null-coalescing operators, checked arithmetic and pattern matching.
Object-oriented questions deal with classes, structs and records, constructors and static constructors, inheritance with virtual, override and new, abstract and sealed classes, interfaces with default members, access modifiers, properties, init accessors and indexers.
The last part covers exceptions and the using statement, delegates, Func, Action and Predicate, events and lambdas, generics and constraints, collections, iterators with yield return, LINQ deferred execution, async and await, attributes, namespaces and partial classes.
Pakistan
India
Bangladesh
C# is a programming language. .NET is the platform that runs it, made up of the Common Language Runtime, which manages memory and execution, and the class libraries that programs use. Other languages such as F# and Visual Basic also run on .NET.
Value and reference types, boxing, string immutability, operators and output questions, OOP with virtual, override, abstract and interfaces, access modifiers, exceptions with finally, delegates and events, collections, LINQ and async/await come up most often.
Last reviewed October 2026