Link Search Menu Expand Document

TOP-10 Advanced C# Interview Questions and Answers

A few frequently asked interview questions for freshers and experienced to achieve success in their interviews and secure a good job.

1. Define Serialization

Ans: Serialization in C# is defined as the method of translating a code into its binary format. Using so makes it easy to quickly save the code and write it to a disk or some other storage unit. We use Serialization when there is a strong need not to lose the initial form of the code.

2. Explain about Delegates with an example.

Ans: A delegate is a reference type variable that holds the reference to a method. The reference may even be altered at runtime. Delegates are primarily used for the execution of events and the call-back methods. Inherently, all delegates originate from the System.Delegate class.

public Delegate int myDel(int number); //declaring a delegate
public class program
public int SubtractNumbers(int a)
int difference = a – 10;
return difference;
public void start()
myDel DelegateExample = SubtractNumbers;

3. Write the syntax to catch an exception in C#

Ans: We use try-catch blocks to catch an exception. The parameter for the catch block is System. Exception type.

catch(Exception ex){

4. Define Generics in C#.

Ans: Generics are used to render reusable classes of code that reduce the redundancy of the code.

  • Improve type protection, efficiency, and optimization
  • Generic Array can be built using System .namespace
  • Generics can be used to create collections
  • Generics prompts the use of a parameterized type

5. Mention the differences between dispose and finalize methods in C#

Ans: Dispose() is called when we want an entity to free unmanaged resources from them. Whereas Finalize() has the same purpose, it does not guarantee the collection of waste from an object.

6. What are C# I/O classes? Mention the commonly used classes.

Ans: C# consists of System.IO namespace, which has classes that compute and execute different file operations, such as creating, removing, opening, closing, etc.

Few commonly used I/O classes are:

  • File – Supports File handling
  • StreamWriter – Usually used to write a stream of characters
  • StreamReader – Usually used to read a stream’s characters
  • StringWriter – Used for writing a StringBuffer
  • StringReader – Used while reading a StringBuffer

7. Define Synchronous and Asynchronous operations

Ans: Synchronization is a means to create a thread-safe code where a single thread can only reach the code at a given time. Because only one thread is used, synchronous programming adversely affects the UI operations that typically occur as users attempt to execute time-consuming processes. The system call returns instantly in Asynchronous operation, enabling the software to execute other processes as the called method performs its share of work in these situations.

8. What are Get and Set Accessor properties?

Ans: Properties make use of these Get and Set Accessors. The property gives a read/write method for the value of a private field. These accessors are used for reaching the private field. Get property is used to return a property’s value, and Set accessor property is used to set the value.

9. What is Multithreading in C#?

Ans: The thread is a series of instructions that allow the program to perform parallel processing when implemented. The thread maintains a lifecycle that begins when a thread is formed and ends shortly after the execution. System. Threading is the namespace it follows, which needs to build threads and use its members. Threads are formed by expanding the thread class. The start() method is used to start the running of a thread. C# can also handle multiple processes/tasks at a time and is accomplished by managing various processes classified as “Multithreading.”

10. What is an Object pool in C#?

Ans: An object pool is a collection of objects available for use. It records the total number of objects that are presently in use. It lowers the overhead of making and re-creating objects.

Other useful articles:

Back to top

© , C Sharp Online — All Rights Reserved - Terms of Use - Privacy Policy