Q. What are the uses of delegates in C#?
A. Below are the list of uses of delegates in C# -
Callback Mechanism
Asynchronous Processing
Abstract and Encapsulate method
Multicasting
Q.What is Nullable Types in C# ?
A. Variable types does not hold null values so to hold the null values we have to use nullable types. So nullable types can have values either null or other values as well.
Eg: Int? mynullablevar = null;.
Q. What is the difference between “as” and “is” operators in C#?
A. “as” operator is used for casting object to type or class.
“is” operator is used for checking the object with type and this will return a Boolean value.
Q. What is enum in C#?
A. enum keyword is used for declaring an enumeration, which consists of named constants and it is called as enumerator lists. Enums are value types in C# and these can’t be inherited. Below is the sample code of using Enums
Eg: enum Fruits { Apple, Orange, Banana, WaterMelon};
Q. Write a sample code to write the contents to text file in C# ?
A. Here is the sample code to write the contents to text file –
Using System.IO;
File.WriteAllText(”mytextfilePath”, “MyTestContent”);.
Q. Explain the types of unit test cases in asp.net?
A. Below are the list of unit test case types –
Positive Test cases
Negative Test cases
Exception Test cases.