Link Search Menu Expand Document

TOP-10 Basic C# Interview Questions and Answers

A few commonly asked interview questions for freshers to achieve success in their Interviews and secure a good job.

1. What is C#?

Ans: C# is a plain, modern, and useful programming language. It is an object-oriented programming language designed by Microsoft. It is a stable and maintained language built by the .NET platform to develop machine code.

2. Mention the differences between Public, Static, and Void keywords

Ans: Variables or methods declared public is available everywhere in the application. Static declared variables or methods are globally usable without making an abstract class. By default, static members are not globally available and depend on the type of access modifier used. A void is a class modifier that states that no value is returned by the method or variable.

3. What are the advantages of using C#?

Ans: Some of the benefits of using C# are:

  • Simple to understand
  • Object-oriented language
  • The syntax is quick to understand
  • Component-oriented
  • A part of the .NET platform

4. What are the various types of comments in C#?

Ans: The various types of comments in C# are:

  • Single-line comments

Example: //This is a single line comment

  • Multiple-line comments

Example: /* This a multiple-line comment

last line of comment */

  • XML comments

Example: /// This is a XML comment

5. Explain about Constructors in C#.

Ans: A constructor is a member of the class which has the same name as the class. The constructor is automatically initialized once the object class is created. It builds the value of data members when the class is initialized.

6. Mention the access modifiers available in C#.


  • Public: If an attribute or method is described as public, it can be accessed from any code section.
  • Private: It is possible to access a private attribute or method from within the class itself.
  • Protected: When a user defines a method or attribute as protected, it can be accessed only within that class and inherits the class.
  • Internal: If an attribute or method is classified as internal, you can access it from that class at the current assembly location
  • Protected Internal: If an attribute or method is designated as protected internal, access is restricted to classes within the current assembly of projects out to different types specified by that class.

7. Illustrate the difference between ref & out parameters

Ans: An argument passed as ref must be initialized before passing to the method, while out parameter does not need to be initialized before passing to a method.

8. What is the use of the 'Using' statement in C#?

Ans: ‘Using’ keyword indicates that the program uses a specific namespace.

9. Define Managed and UnManaged code

Ans: Managed code is a CLR executed code, meaning that all program code is based on the .Net platform. UnManaged code is any code that is implemented by any other platform other than .Net.

10. Mention the different approaches for passing parameters to a method.


  • Value parameters: In this method, an argument's real value is copied to the function's official parameter. In this case, the structured function parameter's modifications do not affect the argument's actual value.
  • Reference Parameters: This approach copies the argument that corresponds to the memory location into the called function. In this situation, changes made to the parameter affect the argument.
  • Output Parameters: This method returns multiple values.

Other useful articles:

Back to top

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