Topic / 95 questions

C# MCQs

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.

Question 01 C#

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

Open question
Advertisement
Question 04 C#

What does the yield return statement do in a C# method?

Correct answer C. It returns one element of an iterator and resumes from that point on the next request

Open question
Advertisement
Question 13 C#

What is the purpose of attributes such as in C#?

Correct answer D. To attach declarative metadata to code elements that tools or reflection can read

Open question
Question 15 C#

What does a file-scoped namespace declaration such as namespace MyApp.Models; do in C# 10 and later?

Correct answer C. It places every type in the file into that namespace without an extra pair of braces

Open question
Advertisement
Question 16 C#

What does the await operator do in a C# async method?

Correct answer C. It suspends the method until the awaited task completes, without blocking the thread

Open question
Question 17 C#

Inside a catch block, what is the difference between throw; and throw ex;?

Correct answer B. throw; keeps the original stack trace, while throw ex; resets it to the current point

Open question
Question 18 C#

When does a finally block execute in C#?

Correct answer B. After the try block and any catch, whether or not an exception occurred, even after return

Open question
Question 20 C#

What does an init accessor, as in public string Name { get; init; }, allow in C#?

Correct answer D. The property can be set only during object initialisation, then becomes read-only

Open question

About C# MCQs

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.

Key facts to remember

  • C# source code compiles to Common Intermediate Language (CIL), which the JIT compiler turns into native code at run time.
  • string is a reference type, but strings are immutable: methods such as ToUpper return a new string.
  • Integer division in C# truncates towards zero, so 7 / 2 is 3 and -7 % 3 is -1.
  • Math.Round uses banker's rounding by default, so Math.Round(2.5) returns 2.
  • LINQ queries such as Where use deferred execution; ToList or Count runs them immediately.

Exams that include C# MCQs

Pakistan

  • NTS and PTS software developer tests
  • PPSC and FPSC Computer Science Lecturer
  • FPSC IT and programmer posts
  • University exams

India

  • Campus placements and company aptitude tests
  • UGC NET Computer Science
  • IBPS IT Officer
  • GATE CS (programming concepts)

Bangladesh

  • BCS (technical cadre)
  • Bank IT officer and programmer tests
  • Government assistant programmer posts

How to prepare for C# MCQs

  1. Learn which built-in types are value types and which are reference types; many output questions depend on copy versus reference behaviour.
  2. Trace code-output questions step by step, writing down each variable after every statement, especially with x++ and ++x.
  3. Remember the difference between override (runtime dispatch) and new (hiding based on the declared type).
  4. For LINQ questions, ask whether the query has actually run yet: deferred queries see later changes to the source collection.

Frequently asked questions

What is the difference between C# and .NET?

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.

Which C# topics are asked most often in job tests?

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