C# Interview Questions & Answers

C# Interview Questions & Answers

The questions to prepare to crack the C# Interview

We all know how difficult ii is nowadays to have a job interview. So, if we have one it is good to be prepared for it rather than just go and seat for the interview. Being prepared will increase our chance of cracking the interview and be the selected candidate for having the job. It is good to know some of the c# interview questions so that we are not surprised when those questions are asked by the interviewer. The main objective of a technical interview is to judge whether you are a suitable person to be a team member of the company. There are certain steps that you must follow so that you can crack the interview. The first and foremost thing is to prepare some question which can probably be asked at the interview. Secondly, you need to practice the different natures of coding which you may think could be the one which the interview may ask you to perform. Create problems yourself and solve those using codes. Before going to the interview leave a gap of few hours from studying so that you do not get overloaded with stuff. It is even better to sleep for an hour before the interview so that you face the interview with a fresh mind. There are certain aspects that you must remember while you are on the hot seat. You must be prepared for anything, ask questions to make yourself clear regarding any doubt that you have regarding the question asked, take your time to answer and be yourself during the interview . If you follow these steps you are certain to crack the interview and be the chosen one.

You are at the right place to prepare yourself with some c# interview questions. Let us discuss some of them so that you can reach that preparation level to crack the interview.

What is C#?

This may be the first question which you may be asked while you seat on the hot seat. The question is really basic but that is the intention of the interviewer to know whether you are comfortable with the basics too. The answer which is known to you is C# is a language which is object oriented, type-safe and can be managed to create another intermediate language which is compiled by.Net framework.

Explain some features of C#?

The features which are supported by C# are:

  • Constructors and Destructors
  • Properties
  • The Passing parameters
  • The Arrays
  • The Main
  • Documentation which is in XML
  • Indexers

Above is the answer to the question asked. Preparation is required so that the answer can be given in an organised manner and the interviewer can feel the confidence that you have over the subject.

Tell some of the advantages of C#?

There are various advantages of C#, below are some:

  • It is easy to learn.
  • C# is subject oriented
  • It is also component oriented
  • It is a part of .Net framework

Tell the IDE’s that are made available by Microsoft for the development of C#?

This question is also very basic but then also the answer is that the IDE’s that are provided are:

  • Visual Studio Express
  • Visual Studio and
  • Visual Web Developer

Explain Managed and Unmanaged Code?

Managed Codes are those which are developed by .Net framework and these codes can be directly used by CLR taking the assistance of managed code execution. The codes that are written using .Net framework is what managed codes are.

Unmanaged codes are those which are created outside the .Net framework. These are applications which do not operate directly under CLR and there are certain languages like C++ which can be used to write such codes.

Explain Boxing and Unboxing?

They are both used for typing conversions but there are some differences.

Boxing: It is the process by means of which a value type data type can be converted to an object or interface which is determined by the type value. When CLR converts a value type to object type then it means that CLR boxes a value. What happens is that it wraps the value inside the system and it is stored in the heap area of the application domain.

Unboxing: This is a process that is used for the extraction of value type from an object or interface. It is seen that boxing can be made to happen implicitly but when unboxing is used there is a necessity of it being explicated by code.

This concept shows that C# has a unified view regarding type system where a value type can be treated as an object.

If you have followed the questions then you must have seen that the interviewer is beginning to go into depth so that your proper knowledge can be judged.

Explain the difference between struct and class as in C#?

They both are data types which are defined by the user but there are some differences. The differences are:


  • This is a value type which is inherited from System.Value Type
  • The usage of this is made when there is a small amount of data involved.
  • In can be inherited to another type
  • It can be abstract in nature
  • This is no necessity of creation of object by the usage of keywords
  • Construction of default constructor is not permitted


  • It is a type of reference and is inherited from System. Object Type.
  • It is used when there is involvement of larger amount of data
  • It can be inherited to other class
  • It is abstract in type
  • Using new keyword with an object in class is not possible
  • Default constructor can be created.

While preparing yourself for this nature of technical interview it is good to go through the c# interview questions. While studying do not memorise the answers by heart. Try to understand the logic of answering and remember the points so that you can frame it in another way if you wish.

Explain the difference between Interface and Abstract Class?

There are certain differences that exist between these two, they are:

  • Any number of interfaces can be integrated into a class but a sub class can only have one abstract class.
  • Non-abstract methods can be there in an abstract class but in interface, all the used methods should be abstract.
  • Declaration or usage of any variable can be done in an abstract class but interface does not allow so.
  • Functions and data members in the abstract class are private in nature but in interface they are public in nature and they cannot be changed manually.
  • For declaration of abstract methods, abstract keywords need to be used in abstract class but in interface such requirement is not there.
  • Usage in multiple inheritances is not permitted in abstract class but it is permissible in an interface.
  • Usage of constructor is done in abstract class but it is not done in interface.

So, what do you think, is the exercise useful? Definitely, you know the answers as because C# is your subject of specialization but it is better to be prepared than to be caught off guard. This exercise will help you to learn how to organize your known answers in the proper manner so that you can impress the interviewer the most.

Explain enum in C#?

This is a value type where there is a set of named constraints which are related. They are often called a enumerator list. The keyword used in enum is required for declaration of enumerator. The type of data is primitive and is defined by users.

Integer can be a type of enum but if you wish to use without int it has to be cast.

For the creation of numeric constants in .Net Framework enum is used. The various members that are in enum are of the enum type.

Points that should be remembered about enum are:

  • It is a enumerated type of data which is used in C#
  • This is used by developers and not by end-users
  • The constant type is strong in enum
  • They are helpful in making the codes used more of the type which can be understood and read.
  • The values are fixed and they can be used as strings and can be processed as an integer.
  • In enum the default type is int. and the approved type that can be used is byte.
  • It is automatically derived from the System.Enum.
  • The value types are created on the stack and not on the heap.

You can understand the necessity of this question set after you read the above answer. The answer is long but it should be properly arranged so that each point is covered and the answer is proper.

Explain the difference between constant and read only?

Users may find them similar but there are some differences which are as follows:

Constant: It is known as “const” in C#. They are immutable values and these values do not change during run time like other functions for as long as the application is running.

Read only: It is known as “readonly” in C# and is the same as constant except that the value can be assayed by the constructor when a new keyword is called for.

Explain ref and out keywords?

There can be three types of parameters in C#, they can be in parameter, out parameter and ref parameter. There are certain features which make ref and out keywords to be different. The features are:


  • The initialisation of the parameter or the argument is required first before it is passed over to ref. But in Out this initialization is not compulsory.
  • No assignment or initialization is required for the value pertaining to the parameter before it is returned to the calling method. Assignment or initialization is required in Out.
  • Usage of Ref is useful while a parameter is passed when the calling method is also to be used for modification. It is useful to use Out when there are multiple values need to be returned from a function.
  • Initialization of the parameter is not required prior to using the calling method. The initialisation is a must in case of Out.
  • Bi-directional passing can happen using Ref. Unidirectional passing is only possible in Out.
  • They are treated differently during run time but during compile time they are treated as same.
  • Properties that are not variables so it cannot be passed as ref or out parameter.

Can you use “this” within a static method?

We can’t utilize this in static strategy since keyword “this” profits a reference to the present example of the class containing it. Static methods don’t have a place with a specific example. They exist without making an instance of the class and call with the name of a class not by example so we can’t utilize this watchword in the assortment of static Methods, however, if there should arise an occurrence of Extension Methods we can utilize it in the function parameters.

The “this” watchword is an exceptional sort of reference variable that is certainly characterized inside every constructor and non-static strategy as a first parameter of the type class in which it is characterized.

Can you define Property in C#.net?

This may be the next of the c# interview questions which you are asked. The answer is definitely known to you but then also to brush up your memory it is good to know the answer and to know how to organize the answer in the proper manner. The answer is that: They are members which offer a mechanism that is flexible in nature that allows to read, write and even to compute the different values of a private field. It is a type of function which is of return type using one or no parameter. There are three types of properties that are used in C#:

  • Read/Write
  • ReadOnly
  • WriteOnly

Explain the extension method and its usage?

Methods that enable one to add a method to the types that are existing without the creation of a new derived type is what extension methods are. It is a special nature of the static method. The “this” modifier is applied to the first parameter and that would be the type of the parameter which is extended.

Explain sealed class in C#?

This is used for the prevention of inheritance of a class from other classes. So, it can be said the sealed modifier can be utilized along with methods to prevent the method to over ride in the child classes.

Explain delegated in C# and how is it used?

A delegate in C# is the same as pointers is in C or C++. It is a variable that is of reference type and can be used to hold references to a method. There can be change in reference when there is a runtime. Much function reference can behold by a delegate and it is called Invocation List. They are specifically used for the implementation of events and the method of call-back. They are derived implicitly from System.Delegate class.

Explain Arrays in C#.Net?

It is a data structure which is powerful in nature and can be sued for solving various problems. It can be seen during creation of different types variables that they have one thing in common and it is that they contain information regarding one item like integer or float. So there must be a solution when there is requirement of manipulation of sets of items. In such a situation Arrays provides the solution. Array is the collection of items that are related and they can be values or reference types. They are immutable and so the dimension number and size are fixed. The properties of Array are as follows:

  • The length of the array cannot be altered after the creation
  • The initialization of the elements are done to the values which are default
  • They are of reference type
  • Rank property determines the dimension number
  • The length can be determined by the method of GetLenght.

So, you can see that there can be innumerable c# interview questions that can be asked in an interview. There are some other things also that we must prepare ourselves while we intend to crack the interview. Firstly we must be in time for the interview. It should not be such that you are late to reach the venue. You must be dressed properly in formals to appear for the interview. You must maintain all the decorum that needs to be maintained while you are in the venue. Last but not the least you must be confident while answering the questions. Take your time to understand the question and then answer. It may so happen that you do not know the answer to a certain question it is better to confess than to give a wrong answer.

Leave a Reply

Close Menu