Jun 12

Basic C# Interview Questions and Answers

91. How does C# differ from C++?

  • C# does not support #include statement. It uses only using statement.
  • In C# , class definition does not use a semicolon at the end.
  • C# does not support multiple code inheritance.
  • Casting in C# is much safer than in c++.
  • In C# switch can also be used on string values.
  • Command line parameters array behave differently in C# as compared to C++.

92. What is nested class?

A Nested classes are classes within classes.

A nested class is any class whose declaration occurs within the body of another class or interface.

93. Can you have parameters for static constructors?

No, static constructors cannot have parameters.

94. Is String is Value Type or Reference Type in C#?

String is an object(Reference Type).

95. Does C# provide copy constructor?

No, C# does not provide copy constructor.

96. Can a class or a struct have multiple constructors?

Yes, a class or a struct can have multiple constructors. Constructors in C# can be overloaded.

97. Can you create an instance of an interface?

No, you cannot create an instance of an interface.

98. Can an Interface contain fields?

No, an Interface cannot contain fields.

99. Can a class have static constructor?

Yes, a class can have static constructor. Static constructors are called automatically, immediately before any static fields are accessed, and are generally used to initialize static class members. It is called automatically before the first instance is created or any static members are referenced. Static constructors are called before instance constructors.

100. What is the main use of delegates in C#?

Delegates are mainly used to define call back methods.

Permanent link to this article: http://zappmania.in/2014/06/12/basic-c-interview-questions-answers.htm

Leave a Reply

Your email address will not be published.