C# is a modern, object-oriented programming language developed by Microsoft and widely used for building web applications, desktop applications, APIs, games, cloud services, and more.

This article contains 100 C# multiple-choice questions covering C# fundamentals, arrays, classes, interfaces, exception handling, inheritance, delegates, lambda expressions, LINQ, generics, XML, reflection, and other important concepts.

Which statement is used to stop loop processing without a condition?

A. break;
B. continue;
C. jump;

Which C# 6 feature reduces the code required to check for null values in a nested object?

A. <IsNullable>
B. ?.
C. Inline declaration for out parameters

What is a jagged array in C#?

A. A multidimensional array with dimensions of various sizes
B. A multidimensional array with dimensions of the same size
C. A single-dimensional array with an unknown size

Which of the following is not a bitwise operator?

A. #
B. ^
C. |
D. &

How can exceptions be handled in C#?

A. None of these
B. throw exception
C. try-catch-finally block
D. ON ERROR RESUME NEXT statement

How can you access the first element from the following array?

int[] x = { 1, 2, 3 };

A. x[1]
B. x.First
C. x[0]

What namespace do you need to include to create a FileStream object in C#?

A. using System.Strings;
B. using System.IO;
C. #include <System.IO>

Which construct is used to handle errors in C#?

A. try, catch, finally
B. Garbage collection
C. The using statement
D. try, catch, deconstruct

Which types of members can you have in a C# class?

A. Methods
B. Constructors
C. Fields
D. All of these

Which is the recognized file extension for C# source files?

A. .csx
B. .cs
C. .c#
D. .cpp
E. .c

Given the following C# statement, what is the value of myInts[1]?

int[] myInts = { 5, 10, 15 };

A. 15
B. 10
C. 5

If your C# class is called Cats, which statement creates an object of type Cats?

A. Cats myCat = new cats();
B. cats myCat = new cats();
C. Cats myCat = new Cats();

Which C# debugging tools are available in Visual Studio?

A. Stepping through your code
B. All of these
C. Breakpoints

What is used in C# to terminate a statement?

A. Ellipsis
B. Semicolon
C. Period
D. Colon

In C#, what would you use to output the contents of a variable to the screen?

A. Console.Write() method
B. System.Write() method
C. Console.Print() method

What type of memory management does C# employ?

A. Managed
B. Manual allocation

Can a class implement multiple interfaces in C#?

A. False
B. True

What is the purpose of the curly braces { and } in C#?

A. They delineate the end of a statement to be executed.
B. They mark the beginning and end of a logical block of code.
C. They mark function code to be used globally.
D. None of these

Which of the following is not a built-in data type in C#?

A. int
B. bool
C. string
D. single

What does a sealed class in C# mean?

A. Derived classes can override some of the class methods.
B. You can create objects of that class type.
C. The class cannot be used as a base class for inheritance.

What information does the manifest of a C# assembly contain?

A. All of these
B. Version information
C. Supported locales

Which symbol is used to concatenate strings in C#?

A. +
B. &
C. &&
D. *
E. ^

Which namespace is needed to use the XML classes provided by C#?

A. using System.Xml;
B. using System.Strings;
C. using System.Parser;
D. using System;

Can you have a single try clause with multiple catch clauses?

A. Yes
B. No

What would the following code print?

string x = "test";
string y = "hello";

Console.WriteLine("{0}, this is a {1}", x, y);

A. This would not compile.
B. hello, this is a test
C. test, this is a hello
D. {0}, this is a {1}

What types can be indexed using an indexer in C#?

A. Struct
B. Both class and struct
C. Class

What is the purpose of the following statement?

~myClass()

A. It is the finalizer for myClass instances.
B. It is a property called myClass.
C. It is a constructor for myClass instances.

What does the expression !false evaluate to?

A. Run-time error
B. 1
C. true
D. Compile-time error
E. false

Which statement provides a convenient way to iterate over items in an array?

A. foreach
B. for
C. switch

What types of inheritance does C# support?

A. All options
B. Interface inheritance
C. Implementation inheritance

Which keyword is used to include namespaces in C#?

A. include
B. import
C. use
D. using

Where would you find the generic Stack<T> class?

A. System.Collections.Generic namespace
B. System.Data namespace
C. System.Collections.Specialized namespace

What does a C# application require to execute managed code?

A. All .NET languages
B. The Common Language Runtime
C. The Java Virtual Machine

Which class is provided in C# for writing XML?

A. XmlReader
B. XmlCreation
C. XmlWriter

If a C# program contains both a run-time error and a compile-time error, which one will you be alerted to first during compilation?

A. Run-time error
B. Both
C. Neither
D. Compile-time error

Which expression is similar to Object.Equals(Person, null)?

A. Person<Nullable>
B. Person == null
C. Person.Null
D. Person?

What is the result of the following expression?

int x = 100 / 0;

A. The system will throw a MathFormatException.
B. x = null
C. The system will throw an InvalidOperationException.
D. The system will throw a DivideByZeroException.
E. x = NaN

What can the Code Document Object Model (CodeDOM) be used for?

A. All of these
B. Allowing developers to create their own code-generation utilities
C. Developing automatic source-code generators

What is the default value of a reference type in C#?

A. 0
B. null
C. Unknown
D. None of these

Which class provides a basic thread creation and management mechanism for most tasks in C#?

A. System.Runtime.Serialization
B. System.Threading.ThreadPool
C. System.IO.Compression

Which of the following is an example of dot notation in C#?

A. Person == true ? Employee : Manager
B. Person.Name;
C. Person ?? Employee

What are the access modifiers available in C#?

A. public, protected, internal, private
B. public, private
C. public, protected, private
D. public, internal, private
E. protected, internal, private

Which of the following is an operator category in C#?

A. Ternary
B. Unary
C. Binary
D. All options

Which programming language family most directly influenced the design of C#?

A. Java
B. Ruby
C. Python
D. JavaScript
E. C++

Are identifiers in C# case-sensitive?

A. False
B. True

Which namespace contains classes such as TextReader, StreamWriter, and File?

A. System.Text
B. System.DataAnnotations
C. System.Data
D. System.IO
E. System.Stream

Which of the following can be valid parameter types for indexers in C#?

A. All of these
B. Integer
C. String
D. Enum

Which operator is used to attach a handler to an event?

A. =>
B. ++
C. +=
D. =
E. ->

If a method needs to be redefined in a derived class, how should it be declared in the base class?

A. Declare it as private.
B. Declare it as virtual.
C. Declare it as partial.

What does the following expression evaluate to if number is -6?

(number <= 10) && (number >= 0)

A. True
B. False

Which keyword prevents a class from being inherited?

A. static
B. extern
C. out
D. sealed

Which of the following are valid ways to write comments in C#?

A. Both
B. //
C. /* */
D. Neither

Which keyword handles unspecified cases in a switch statement?

A. else(...)
B. if(...)
C. default
D. standard
E. finally

What is the default value of the first member in the following C# enum?

public enum Days
{
    Monday,
    Tuesday,
    Wednesday,
    Thursday,
    Friday,
    Saturday,
    Sunday
}

A. 0
B. None of these
C. 1
D. "Monday"

What is the purpose of the ref keyword in C#?

A. It allows you to reference a variable value from anywhere inside your program.
B. It allows you to change the reference address of the variable.
C. It allows you to pass a parameter to a method by reference instead of by value.

Which of the following best describes a C# interface?

A. An interface contains only methods and delegates.
B. An interface contains signatures for methods, delegates, events, properties, and other supported members.
C. An interface is a keyword that allows classes to inherit from other classes.
D. An interface is the UI presented to the user in an application.
E. An interface allows you to define how a class will be named.

What does the C# statement using System; mean?

A. Create a namespace called System from the classes defined in this file.
B. All of these
C. Import the System namespace so its types can be referenced without fully qualifying their names.

What must overloaded methods have in common?

A. None of these
B. The same parameter types
C. The same number of parameters
D. The same name

What is the expected value of x?

var x = default(DateTime);

A. 1/1/0001 12:00:00 AM
B. 0
C. null
D. Compiler error
E. An exception will be thrown

What does the protected modifier mean when used on a class member?

A. No other class instances can access it.
B. It becomes the default access level for all members of the class.
C. The member can be accessed from the containing class and derived classes.

Which classes can be used for navigating through an XML file?

A. XmlDocument
B. None of these
C. Both XmlDocument and XmlReader
D. XmlReader

What can a static class in C# contain?

A. Both private and public members
B. None of these
C. Both static and non-static members
D. Static members

Can you change the value of a variable while debugging a C# application?

A. Yes. When debugging in Visual Studio, you can modify variables using debugging windows such as the Immediate window.
B. No. Code gets locked down during run time.

How do you specify a reverse lambda expression?

A. (c => c.Person)
B. There is no such thing.
C. (c <= c.Person)
D. (c.Person <= c)

How can methods accept a variable number of arguments in C#?

A. By using ... in the argument list
B. By using the params keyword in the argument list
C. They do not exist

Which statement correctly assigns a new event handler?

public delegate void EventHandler();

public static event EventHandler handler;

static void Bar()
{
    Console.WriteLine("Bar");
}

A. handler += new EventHandler(Bar);
B. handler = new Event(Bar);
C. handler += new Event(Bar);
D. handler = new EventHandler(Bar);

What does the following class definition represent?

public class Foo
{
}

A. It is a class that contains one or more arrays.
B. This class extends the T class.
C. It is a generic class.
D. This class implements the T class.
E. None of these

What is the value of result after executing the following code?

bool test = true;
string result = test ? "abc" : "def";

A. abcdef
B. testabc
C. abc
D. def
E. It does not compile.

Which attribute specifies a method to run after deserialization occurs?

A. OnDeserialized
B. OnSerializing
C. OnSerialized
D. OnDeserializing

What is the following expression an example of?

c => c.Name == "Ben"

A. LINQ
B. Dynamic typing
C. Generics
D. A lambda expression

What is unique about an abstract class in C#?

A. You can only instantiate a reference to it.
B. You cannot create an instance of it.
C. You cannot inherit another class from it.

How do you call a static method from a static class?

public static class OutputClass
{
    public static void PrintMsg()
    {
    }
}

A. OutputClass.PrintMsg();
B. OutputClass oc = new OutputClass(); oc.PrintMsg();
C. Both of these

What is the full name of the type represented by the int keyword?

A. System.Int64
B. System.Int32
C. System.Math.Int32
D. System.Int
E. Int32

What happens when you use #region and #endregion in C#?

#region Debug

// Block of code here

#endregion

A. The entire block of code is commented out.
B. The entire block of code is executed only in debug mode.
C. You can visually expand or collapse the block of code in the editor.

What is the System.String.Format method used for?

A. Replacing format items in a specified string with the string representation of corresponding objects.
B. Coloring an input string with different colors for text visualization.
C. Making the specified string word-wrapped for text visualization.
D. Prettifying code snippets.
E. Automatically formatting decimals into a currency string representation.

How do you instantiate a generic list of objects in C#?

A. myList = new List<Object>();
B. myList = new List<Object>;
C. myList = new List<typeof(Object)>();
D. myList = new List<>(Object);

What members can an interface contain in C#?

A. All of these
B. Events
C. Methods
D. Indexers
E. Properties

Which keyword is required to compile C# code that uses pointers?

A. static
B. void
C. unsafe

How is inheritance specified in a C# class definition?

A. The keyword extends
B. The : symbol
C. All of the answers are correct
D. The keyword inherits

Which symbol allows the creation of verbatim string literals in C#?

A. @
B. ~
C. ^
D. `
E. #

What does the public modifier mean when used on a class?

A. No other classes can access it inside your program.
B. The class can be accessed by external assemblies, subject to assembly accessibility.
C. It becomes the default access level for all classes in your program.

What is reflection used for in C#?

A. Discovering types and methods in assemblies
B. All of these
C. Viewing metadata
D. Dynamically invoking methods

What does the extern keyword indicate?

A. The method is implemented within the current project.
B. The method is implemented externally.
C. The method is implemented within one of the C# System classes.

What is C# code compiled into?

A. x86/x64-specific native code, depending on compilation options
B. Common Intermediate Language (CIL), which is compiled into CPU-specific native code at run time
C. Neutral bytecode executed directly by the .NET virtual machine

How do you declare a C# class as an attribute?

A. public class MyAttribute as System.Attribute
B. public class MyAttribute
C. public class MyAttribute : System.Attribute

What is the default member accessibility for members declared inside a C# class?

A. private
B. protected
C. public

How many items can the following array hold?

string[] names = new string[2];

A. 1
B. 3
C. 0
D. 2

Which exception is thrown when accessing an array outside its bounds?

A. ArrayTypeMismatchException
B. InsufficientExecutionStackException
C. IndexOutOfRangeException
D. ArrayIndexOutOfBounds

How does a struct differ from a class in C#?

A. A class can be stored as either a reference or a value.
B. A struct can contain implementation inheritance.
C. A struct is a value type, whereas a class is a reference type.

Is the [Flags] attribute required for an enum to be used with bitwise operations?

A. True
B. False

Which of the following is not a C# keyword?

A. is
B. as
C. of
D. if
E. in

Which of the following is an example of a valid C# Main method?

A. All of these
B. None of these
C. static void Main()
D. static int main()

Lambda expressions can be used as a short-form way to:

A. Create generic types
B. Assign a value to a delegate

Can you have a nullable DateTime in C#?

A. No
B. Yes

How do you implement your own version of the ToString() method in a class?

A. public string ToString() { }
B. public override string ToString() { }
C. public virtual string ToString() { }
D. private override string ToString() { }
E. public override ToString() { }

Which interface must a class implement to be used with a using statement?

A. ICustomAdapter
B. IUsing
C. IMemoryManagement
D. IDisposable
E. Disposable

Which statement about assigning a List to an IEnumerable is correct?

IEnumerable aList = new List();

A. Illegal because List does not implement the IEnumerable interface.
B. Illegal because the constructor of List cannot be empty.
C. Legal
D. Illegal because it is not allowed to create an object of an interface type.

What is the default visibility for members of classes and structs in C#?

A. private
B. internal
C. protected
D. public

What syntax is used for XML documentation comments in C#?

A. ///
B. <!--
C. //

Conclusion

These C# multiple-choice questions cover essential concepts for developers preparing for C# interviews, exams, assessments, and technical discussions.

The questions cover C# syntax, arrays, data types, classes, interfaces, inheritance, exception handling, delegates, events, generics, lambda expressions, XML, reflection, debugging, and other fundamental .NET concepts.