TechieClues TechieClues
Updated date Jan 14, 2024
Most popular and frequently asked C# interview questions and answers for freshers and experienced C# developers who plan to attend C# and .NET interviews.
  • 3.6k
  • 0
  • 0

1. What is the difference between Public, Static, void?

  • Static: When using Static, the object is not required to access static members.
  • Public: This keyword specifies that the method of the class can be accessible publicly
  • Void: This keyword specifies that the method does not have a return type

2. What is C# also mention some features of C#.

C # is the best language for writing Microsoft .NET applications. C # gives rapid application development in Visual Basic the power of C ++. The syntax is similar to C ++ syntax and meets 100% OOP requirements as follows:

  • Abstraction
  • Encapsulation
  • Polymorphism
  • Inheritance

3. Please elaborate on the reason why we use C#

Choosing C # as your first programming language helps you understand many concepts quite easily. Setting up a Hello project is very intuitive. As one of the most popular programming languages, you have a number of documents on the internet that can help you troubleshoot and correct errors in your code.

One of the main selling points for .NET (C #) is that Microsoft provides a wide range of powerful tools that can help programmers develop better applications. By far the most important of all these tools in Visual Studio. Visual Studio is a very powerful and rich integrated development environment (IDE) that provides a large number of tools to support application development.

Through C# we can develop a number of applications like

  • Desktop applications
  • Web applications
  • Mobile applications
  • Games

4. What are the advantages of C#?

  • Simple and fast
  • High scalability
  • Cross-platform
  • No buffering

5. What are the different types of comments in C#?

  • Single line comment denoted with //
  • Multiline comments denoted with /*
  • XML comment denoted by ///

6. Elaborate the code compilation process in C#?

These steps involved in the C# compilation process

  • Clubbing newly created code
  • Executing assembly
  • CLR

7. List down the available access modifier in the C#?

  • Public
  • Private
  • Protected
  • Internal
  • Protected internal

8. Mention the different IDE’s provided by Microsoft?

  • Visual Studio
  • Visual web developer

9. Distinguish between continue and break statement?

Using break, you can jump over the block of code while using continue you can jump over the iteration and continue the execution

10. What are the different approaches to pass the parameter to a function?

  • Value type parameter
  • Reference type parameter
  • Output parameter

11. Distinguish between finally finalize block?

Finally block called after the execution of try catch block while finalize called just before the garbage collection

12. What is managed and unmanaged code?

Managed Code is code generated by the .NET compiler. It does not depend on the target computer as it is performed by CLR (Common Language Runtime) and not the operating system itself. The CLR and admin code do not provide many benefits to developers, such as waste collection, type checking, and exemption management.

On the other hand, the Unmanaged Code is compiled directly with the built-in machine code and depends on the architecture of the target machine. It is executed directly by the operating system. For unmanaged code, the developer must consider memory usage and allocation (mainly due to memory leakage), type protection, and manual exceptions. In .NET, Visual Basic, and the C # compiler create managed code. To get unmanaged code, the application must be written in C or C ++.

13. Differentiate between class and object?

A class is a description of an object and what a class representation is an object. We can think of the class as a model for the object: it describes all the properties, methods, states, and behaviors that the implementing object will have.

An object is an instance of a class, and a class does not become an object until an instance is created. There can be multiple instances of objects based on a class, each with different properties.

14. What is an abstract class?

An abstract class cannot be instantiated. It only allows other classes to inherit from it, but cannot be instantiated. The advantage is that it uses certain hierarchies for all subclasses. Basically, it is a type of contract that forces all subclasses to maintain the same hierarchies or standards.

15. What is a sealed class?

Sealed classes are used to limit the inheritance function of object-oriented programming. When a class is defined as a sealed class, the class cannot be inherited. Visual Basic .NET uses the non-transferable keyword to seal. If a class is derived from a sealed class, the compiler returns an error.

16. Elaborate the fundamentals of oop?

  • Inheritance
  • Abstraction
  • Polymorphism
  • Encapsulation

17. How can we inherit one class from another class?

The colon (:) is used as an inheritance operator in the C#. place the colon and class name

18. What is method overloading?

Create the number of methods with the same name and type and class but with different parameters is known as method overloading.

19. Differentiate between method overloading and overriding?

Method overload

  • Create the number of methods with the same name and class but with different parameters
  • It is performed within class
  • The parameter must be the same

Method overriding

  • If the definition of the derived class change method behavior should be changed
  • Occurs in two classes
  • A parameter must be different

20. Define an interface?

Like a class, Interface can have methods, properties, events, and indexers as members. But the interfaces only contain the membership statement. The implementation of the interface members is given by the class that implicitly or explicitly implements the interface.

21. Distinguish between class and struct?

Class Structure
Classes are a kind of reference value type
All reference types are arranged in a smaller memory stack memory used to assign the value type.
The class has unlimited functionality Struct has limited functionality.
commonly used in large programs Used in the small program
Classes can be constructive or destructive A structure does not have a constructor or destroyer without parameters

22. Differentiate between virtual and abstract method?


  • It must have a default implementation
  • It is overridden by the keyword override
  • The virtual method has code


  • It does not have any implementation
  • It forces the derived class to override the method
  • They don’t have actual code in them.

23. Illustrate the namespace in C#?

A namespace is a collection of classes and another namespace. We are using the namespace to organize our project.

24. Define the 'using' statement?

Basically, with this keyword, we add a different namespace to our project. For the usage for their classes. In the case of C#, the System namespace is where many useful things are described. One of these useful things given C# is that the Console class can let me write things that can appear on the screen ahead of the user to this as Console I even have to inform the compiler I'm using the System namespace. The means that if I ask something by a specific name the compiler will look in the System to ascertain if there's anything matching that name

25. Define boxing and unboxing?

Converting the value type into a reference type is known as boxing. While explicit conversion of the same type is known as unboxing

26. What is an array?

An array is used to store the multiple variables of the same data type. The array always starts from the zero indexes. Each index in the array holds a value.

<data type> [] <identifier> = new <data type>[<size of array>];

27. What is a jagged array?

A jagged array reference to an array of array. It is a nested array whose elements are the arrays. The element can be of different size dimensions.

28. Distinguish between array and array list?


  • Use the vector array for storing the element
  • The size of the array must be defined
  • Typecasting is not necessary

Array List:

  • Used linked list to store the element
  • There is no need to specify the size
  • Typecasting is necessary

29. What is collection?

The collection is work as the container for the instance of the other classes every class implement collection interface

30. Illustrate the serialization?

It is a process that involves the conversion of one code of block into its binary format.

31. What is parsing?

Conversion of string into to other datatypes is known as parsing for example

String a = “123”;

Int data = int.Parse(a);

32. Explain about delegate?

A delegated object contains a reference to a method. Delegates in C # are the same as function markers in C or C ++. A delegated object is a reference type variable that is used to contain a reference to a method. The reference can be changed by runtime owned by a delegated object, a delegated object can contain many reference functions, also known as call list, which refers to functions in a FIFO sequence, we can refer to new functions in this list at runtime of += operator and can be deleted by -= operator.

33. Distinguish between string and StringBuilder?


  • It is immutable
  • Cannot perform a variety of operations.


  • It is mutable.
  • Support variety of operations on string builder.
  • The new memory is not allocated.

34. What is LINQ?

LINQ is an acronym for Language Built-in Query and was introduced with Visual Studio 2008. LINQ is a set of functions that extends query functions to the syntax of the .NET language by adding sets of new standard query operators that allow data manipulation, independently of the data source. Supported data sources are .NET Framework collections, SQL Server databases, ADO.NET datasets, XML documents, and any object collection that supports IEnumerable or the generic IEnumerable interface <T> in both C # and Visual Basic. In short, LINQ bridges the gap between the object world and the data world.

35. What is garbage collection?

Garbage collection is a low-priority process that acts as an automated memory manager that manages the allocation and release of memory to applications. Each time a new object is created, the common language execution allocates memory time to that object from the managed stack. As long as free memory space is available on the managed stack, the runtime continues to allocate space for new objects. However, memory is not infinite, and when an application fills the memory space in the heap, garbage collection kicks in to free up memory. When the garbage collector performs a collection, it searches for objects in the managed stack that are no longer in use by the application and takes the necessary steps to restore memory. Garbage collection stops all running threads, finds any objects on the stack that cannot be accessed by the main program and deletes them. Then rearrange all the objects on the stack to make room and wrap all references to those objects on both the stack and the stack.

36. Please elaborate on the following acronyms in .NET stand for IL, CIL, MSIL, CLI, and JIT?

IL or Intermediate Language is partially compiled processor-independent code. IL code is compiled into native machine code using the current environment properties using the Just-In-Time (JIT) compiler.

The JIT compiler translates IL code into compilation code and uses the target computer's CPU architecture to run the .NET application. In .NET, it is called Common Intermediate Language (CIL), and in the early days of .NET, it was called Microsoft Intermediate Language (MSIL).

CLI or Common Language Infrastructure is an open specification developed by Microsoft. It is a compiled code library used for deployment, version control, and security. There are two types of CLI in .NET: processing units (EXEs) and library units (DLLs).

37. Distinguish between heap and stack?

The short answer would be: the value of stacks (types inherited from System.ValueType) are stored on the stack, and reference types (types inherited from System.Object) are stored on the stack.

We can say that the stack is responsible for keeping track of what is actually being done and where each thread is executing (each thread has its own stack). The stack, on the other hand, is responsible for tracking more specific data or objects.

38. Please elaborate on inheritance and why we use it?

Inheritance is one of the strong concepts of object-oriented programming which collectively transforms encapsulation into polymorphism. Through inheritance, developers can create new classes that reuse, develop, and modify behaviors defined in other classes. This allows code reuse in acceleration or development. Inheritance allows developers to write and debug a single class once and reuse the same code as the basis for new classes. The class whose members are inherited is called the base class, and the class that inherits these members is called the derived class. By default, all classes can be inherited in .NET.

39. Distinguish between an Interface and an Abstract Class?

An interface simply explains a contract or behavior that implementing classes must-have. You can only declare properties, methods, and events without access modifiers. All specified members must be implemented.

An abstract class provides a partial implementation of a function and some abstract/virtual members to be implemented by inherited entities. You can also declare fields.

40. Differentiate between System.Array.CopyTo() and System.Array.Clone()?

The Clone() method returns a new array object (a small copy) that contains all of the elements of the original array. CopyTo() method copies all the elements into another array that is already existing. A low copy means that the content (each element in the array) contains references to the same object as the elements in the original array. A full copy (which neither of these methods does) creates a new instance of the object for each item, resulting in a different but identical object.

41. Differentiate between “is” and “as” operator?

"Is" operator: In the C # language, we use the "is" operator to control the object type. If the two objects are of the same type, it is returned true and false otherwise.

operator "as": The operator "as" behaves like the operator "is". The only difference is that it returns the object if they both support that type, otherwise it returns null.

42. Differentiate between Equality Operator (==) and Equals () Method?

The == Operator and Equals() methods are used to compare two data elements of type value or data elements of type reference. == is the comparison operator and the Equals() method compares the contents of a string

43. Elaborate the indexer?

Indexing allows classes to be used in a more intuitive way. C # introduces a new concept called indexing, which is used to treat an object like an array. Indexers are commonly referred to as smart arrays in C #. They are not an integral part of object-oriented programming.

44. Differentiate through exception and through clause?

The fundamental difference is that the Throw exception decomposes, making it difficult to find the original line number of the code that caused the exception. Throw basically keeps track of the stack information and appends it to the stack information unless it is started.

45. Can we use multiple catch block execution?

We can use multiple catch blocks on each attempt, but when the debugger throws exceptions, all the catches match that type of exception with its signature and catch the exception for each catch block, which means we can have several catch blocks but only execute immediately.

46. Explain the usage of the extension method?

An extension method is a static method in a static class where the modifier "this" is applied to the first parameter. The type of the first parameter is the extended type.

47. Can we inherit private class members to the derived class?

Yes, the private members are also inherited in the derived class, but we can't access them. Attempts to access a private base class member in the derived class report a compile-time error.

48. Elaborate enum?

An enum is a type of value with a set of associated named constants, often called a list of counters. The keyword enum is used to declare a count. This is a primitive custom data type. An enum can be an integer (float, int, byte, double, etc.).

49. Explain Get and Set in properties?

Get and set parts or blocks of a property are called accessors. These are useful for limiting the availability of a property, the set accessor specifies that we can assign a value to a private field in property and without the set access property it is like a read-only field. Through get accessor we can access the value of the private field, in other words, it returns a single value. A get accessor indicates that we can publicly access the value of a field.

We have the three types of properties

  • Reading, writing.
  • Read-only.
  • Writing only

50. Elaborate deadlock?

A deadlock is a situation in which one process cannot complete its execution because two or more processes are waiting for the other to complete. This usually happens on multiple threads



I specialize in creating and sharing insightful content encompassing various programming languages and technologies. My expertise extends to Python, PHP, Java, ... For more detailed information, please check out the user profile

Comments (0)

There are no comments. Be the first to comment!!!