C# Interview Questions and Answers Part 1

C# Questions and Answers :

1. What are the uses of volatile keywords in c#?
Ans. Volatile is one of the modifier which reduces concurrency issues.Generally these keywords are used in multi threading environment.

2. Why we use params in c#?
Ans. Params keyword is generally used to pass more than one arguments to a function.
public static int Testparams(params int[] values)
//Calling functions
 Testparams(5, 6);
 Testparams(5, 5, 5);
 Testparams(5, 6,7, 8);

3. What is Hungarian notatoin?
Ans. Declaring variable with datatype as prefix.
Example : int icount = 0; string strName ="test";

4. What is indexer in c#?
Ans. Indexer is a class member that allows an object to be indexed like an array. An indexer is usually added to a class when the class which contains an internal collection and you wish to access this internal collection using array-like syntax.

5. What is internal keyword in c#?
Ans. Internal types are accessible only within files in the same assembly.The encapsulation is limited to assembly.

6. Name few comment sections in c#?
Ans. <summary>,<param>,<return> and <exception>

7.Can we declare attributes as constant in c#?
Ans. No Attributes cannot be declared as const.Morever Attributes referring to const fields will only have getters, not setters.

8. What is the use of extern keyword in c#?
Ans. The extern keyword is used for calling non-C# function. Generally it is used in combination with "DllImport" attribute.


Receive Quality Tutorials Straight in your Inbox by submitting your Email below:

Delivered by FeedBurner

Protected by Copyscape Duplicate Content Checker