C# Interview Questions and Answers

1. Would you explain What is C# and its features?
C# is a simple, type-safe, modern, general-purpose, managed and object-oriented programming language developed by Microsoft for writing .NET applications. The syntax used in C# is mostly same as those of C++. It meets all the conditions of OOPs completely like abstraction, inheritance, encapsulation, polymorphism etc.
C# has following features-
  1. Boolean Conditions
  2. Constructors and Destructors
  3. Assembly Versioning
  4. Properties and Events
  5. Delegates and Events Management
  6. Arrays
  7. Properties
  8. Indexers
  9. Conditional Compilation
  10. Integration with Windows
  11. Standard Library
  12. Automatic Garbage Collection
  13. Passing Parameters
  14. XML Documentation
  15. Easy-to-use Generics
  16. Simple Multithreading
  17. LINQ and Lambda Expressions

2. Could you give me reasons to use C# language?
There is variety of reasons to use C# language-
  1. Easy to learn
  2. Object oriented
  3. General purpose programming language
  4. Efficient application development
  5. Structured language
  6. Component oriented
  7. Part of .Net Framework
  8. Compiled on a variety of platforms

3. Would you define an object.
Object is an instance of a class that is created dynamically. An object is a block of memory that has been allocated and configured in a class. There can be many objects in a class and can be stored in either a named variable or in an array or collection With the help of objects, we can access the member of a class using the dot.

4. Can you explain Constructors with its types?
Constructor is a special method of the class which is automatically invoked when an object of the class is created .Constructors are mainly used for object initialization and memory allocation of its class. If you do not create a constructor in the class, the compiler will automatically create a default constructor in the class to initialize all numeric fields in the class to zero and all string and object fields to null.


[Access Modifier] ClassName([Parameters])
Constructors are of 5 types
  • Default Constructor
  • Parameterized Constructor
  • Copy Constructor
  • Static Constructor
  • Private Constructor

5. What do you mean by Constructor Overloading?
Constructor overloading means that we can have more than one constructor with different parameters. It is simple to creating an overloaded constructor by adding additional constructors to the code. Each constructor has a unique signature.

using System;

public Class OC
public OC()
//Default constructor
public OC(int Marks)
// Constructor with single parameter
public OC(int Marks, string Subject)
// Constructor with two parameters

6. Please define Static Constructor.
Static constructor is a constructor that is called before the first object of the class is created. It is called automatically before the first instance is created. It is used to initialize any static data, or to perform a particular action that needs performed once only. The user has no control on when the static constructor is executed in the program but it is definitely before the first object creation. There should not be any parameter in static constructor. It cannot be called directly. It can access only the static members of the class. Only one static constructor is allowed.

7. What do you understand by Private Constructor.
Private constructor is a constructor with "private" access modifier in a class. It is an instance constructor used in class that contain static member only. If a class has one or more private constructor and no public constructor then other classes are not allowed to create either create the object of the class or inherit it. In order to access the methods or properties in a class having private constructor, we have to assign methods or properties with "static" keyword. With private constructor, we can also have public constructor (overloaded constructor).

8. Can you describe Copy Constructor?
A copy constructor is a parameterized constructor that allows to copy the data stored in the member variables of an object of the class into another object. It is used to initialize new instance to the values of an existing instance.

9. Differentiate between method overriding and method overloading.
Method overriding will create two or more methods with same name and same parameter in different classes but method overloading will create more than one method with same name but different parameter in same class.

10. How many types of comments are found in C#?
Following types of comments are there in C# -

Single Line Comment (//)
// Single line comment

Multiline Comments ( /* */)
Multiline comment
Line 2 comment
Last line comment

XML Comments ( ///)
/// Summary1;
/// Note;
/// Summary2;

submit to reddit
HTML Tutorial
HTML5 Tutorial
Bootstrap3 Tutorial
Javascript Tutorial
TypeScript Tutorial
AngularJS Tutorial
CSharp Tutorial
PHP Tutorial
Developer Tools
Google MAP API V3
Google MAP API V3
Contact Us
Advertise with Us
Privacy Policy
Stay connected. We actually like you. If you want to get up to the minute updates, then connect with us on your fav below.
Twitter   Linkedin   Facebook   Google+    RSS   Pinterest
Protected by Copyscape Original Content Checker
Copyright ©2017 www.techstrikers.com Unauthorized reproduction/replication of any part of this site is prohibited.