Advertisement

Information Technology

C# Programming Interview Questions & Answers

Prepare for your C# Programming interview with 49+ curated questions and answers, organised into 6 topics from beginner to advanced. Each topic also has tutorials and MCQ practice.

6topics 49questions last updated
Advertisement

.NET Framework Fundamentals

All 14 questions
  1. COM, or Component Object Model, is an older Microsoft technology that allows software components to communicate with each other regardless of the programming language they were wri…

  2. dot NET represents a complete software development platform created by Microsoft that provides everything needed to build, run, and manage modern applications, including a runtime…

  3. A framework is a pre built set of tools, libraries, and rules that developers use as a foundation to build applications faster and more consistently, instead of writing every piece…

  4. The Common Language Runtime, or CLR, is the execution engine of dot NET that manages running applications, handling tasks such as memory management through garbage collection, exce…

  5. dot NET is a free, open source developer platform created by Microsoft for building many different types of applications, including web, mobile, desktop, gaming, IoT, and cloud bas…

Access Modifiers in C#

All 7 questions
  1. Access modifiers in C# are keywords that control the visibility and accessibility of classes, methods, properties, and other members from other parts of the code. The main access m…

  2. No, not every access modifier can be applied to every kind of type or member. For example, top level classes and interfaces defined directly within a namespace can only be declared…

  3. No, a derived class cannot have greater accessibility than its base class, since doing so would create a situation where code could access the derived class but not the base class…

  4. No, a member cannot be more accessible than the type that contains it, since that would create a contradiction where the member is technically reachable but the type needed to acce…

  5. No, destructors in C# cannot have any access modifiers applied to them, since they are called automatically by the garbage collector rather than being called directly by other code…

C# Language Fundamentals

All 4 questions
  1. IEnumerable is an interface representing a sequence of items that can be enumerated one at a time using deferred execution, meaning the actual data is only produced when you iterat…

  2. A class is considered an abstract data type because it defines a blueprint that combines both data, in the form of fields and properties, and behavior, in the form of methods, whil…

  3. C# 7 introduced several useful features including tuples with named elements for returning multiple values from a method more cleanly, pattern matching with the is and switch keywo…

  4. Every class in C# inherits a ToString method from the base Object class, but by default it simply returns the full name of the type, which is rarely useful for debugging or display…

Data Types in C#

All 9 questions
  1. C# data types fall into two broad classifications called value types and reference types. Value types, such as int, double, and bool, store their actual data directly in the memory…

  2. You create user defined data types in C# using constructs like class, struct, enum, and interface, each serving a different purpose. A class or struct lets you group related fields…

  3. int is simply a C# keyword alias for the System.Int32 struct provided by the Base Class Library, meaning both represent exactly the same 32 bit signed integer type and can be used…

  4. Value types store their actual data directly within their own memory allocation, typically on the stack, and copying a value type variable creates a completely independent copy of…

  5. Casting a data type means explicitly converting a value from one data type to another, such as converting a double to an int, which C# allows either implicitly when there is no ris…

Properties in C#

All 7 questions
  1. Properties in C# are members that provide a flexible way to read, write, or compute the value of a private field while still exposing that access through a simple, field like synta…

  2. C# supports several types of properties, including read write properties that have both get and set accessors, read only properties that only expose a get accessor, write only prop…

  3. Properties offer several advantages over exposing raw public fields, including the ability to add validation logic when a value is set, the ability to make a member effectively rea…

  4. A static property belongs to the class itself rather than to any specific instance of that class, meaning it is accessed through the class name directly and shares the exact same v…

  5. A virtual property is a property declared in a base class using the virtual keyword, which allows a derived class to override its behavior using the override keyword, giving subcla…

Strings in C#

All 8 questions
  1. The string keyword in C# is simply an alias for the System.String class provided by the language for convenience, meaning both refer to exactly the same type and can be used interc…

  2. String objects in C# are immutable, meaning that once a string is created, its actual content in memory can never be changed. Any operation that appears to modify a string, such as…

  3. Saying that string objects are immutable means the actual character data stored inside a string object cannot be altered after it has been created in memory. When you assign a new…

  4. A verbatim string literal in C# is created by placing an at symbol directly before the opening quotation mark, and it tells the compiler to treat the string exactly as written, ign…

  5. You can create an empty string in C# in a few equivalent ways, including assigning two double quotation marks with nothing between them, using the built in String.Empty field, or c…