C# Interview Questions and Answers (958) - Page 9

What is the use of GetInvocationList() in C# delegates?

GetInvocationList() returns an array of System.Delegate types, each representing a particular method that may be invoked.
What are the different C# preprocessor directives?

#region , #endregion :- Used to mark sections of code that can be collapsed.

#define , #undef :-Used to define and undefine conditional compilation symbols.

#if , #elif , #else , #endif :- These are used to conditionally skip sections of source code.
What is the use of stackalloc keyword in C#?

In an unsafe context it is used to allocate C# array directly on the stack.
Which operators in C# provides automatic detection of arithmetic overflow and underflow conditions?

'checked' and 'unchecked' keywords provide automatic detection of arithmetic overflow and underflow conditions.
What is the CIL representation of implicit and explicit keywords in C#?

The CIL representation is op_Implicit and op_Explicit respectively.
What is the use of ?? operator in C#?

This operator allows you to assign a value to a nullable type if the retrieved value is in fact null.
What are the different Iteration Constructs in C#?

for loop
foreach/in loop
while loop
do/while loop
What do you mean by properties in C#?

Property acts as a cross link between the field and the method . Actually it behaves as a field. We can retrieve and store data from the field using property.

The compiler automatically translates the field like property into a call like special method called as 'accessor" . In property there are two accessor and that are used to save value and retrieve value from the field. The two properties are 'get' and 'set'.

The get property is used to retrieve a value from the field and the set property is used to assign a value to a field .

Depending on there use properties are categorised into three types,

ReadWrite Property :- When both get and set properties are present it is called as ReadWrite Property.

ReadOnly Property :- When there is only get accessor it is called as ReadOnly Property.

WriteOnly Property :- When there is only set accessor, it is called as WriteOnly Property.
Which class defines different events for controls in C#?

The "Control" class defines a number of events that are common to many controls.
What is the use of param keyword in C#?

In C# param parameter allows us to create a method that may be sent to a set of identically typed arguments as a single logical parameter.
Which enumeration defines different PenCap in C#?

LineCap enumeration which defines different pen cap styles as follows,

public enum LineCap

{
Flat, Square, Round, Triangle, NoAncher, SquareAnchor,
RoundAnchor, DiamondAnchor, ArrowAnchor, AnchorMask, Custom
}

When TimerCallback delegate is used?

Many application have the need to call a specific method during regular intervals. For such situations we can use the System.Threading.Timer type in conjunction with a related delegate named TimerCallback.
What are the different compiler generated methods when a .NET delegate is compiled?

Compilation of a .NET delegate results in a sealed class with three compiler generated methods whose parameters and return values are dependent on the delegate declaration. The methods are,
Invoke()
BeginInvoke() and
EndInvoke().
Found this useful, bookmark this page to the blog or social networking websites. Page copy protected against web site content infringement by Copyscape

 Interview Questions and Answers Categories