1.What is C-Sharp (C#)?
C# is a type-safe, managed and object oriented language, which is compiled by .Net framework for generating intermediate language (IL).
2.Explain the types of comments in C#?
Below are the types of comments in C# –
- Single Line Comment Eg : //
- Multiline Comments Eg: /* */
- XML Comments Eg : ///
3.List out the differences between Array and ArrayList in C#?
Array stores the values or elements of same data type but arraylist stores values of different datatypes.
Arrays will use the fixed length but arraylist does not uses fixed length like array.
4.Why to use “using” in C#?
“Using” statement calls – “dispose” method internally, whenever any exception occurred in any method call and in “Using” statement objects are read only and cannot be reassignable or modifiable.
5.Explain namespaces in C#?
Namespaces are containers for the classes. We will use namespaces for grouping the related classes in C#. “Using” keyword can be used for using the namespace in other namespace.
6.Explain “static” keyword in C#?
“Static” keyword can be used for declaring a static member. If the class is made static then all the members of the class are also made static. If the variable is made static then it will have a single instance and the value change is updated in this instance.
7.Why to use “finally” block in C#?
“Finally” block will be executed irrespective of exception. So while executing the code in try block when exception is occurred, control is returned to catch block and at last “finally” block will be executed. So closing connection to database / releasing the file handlers can be kept in “finally” block.
8.Can we have only “try” block without “catch” block in C#?
Yes we can have only try block without catch block.
9.What is the difference between “out” and “ref” parameters in C#?
“out” parameter can be passed to a method and it need not be initialized where as “ref” parameter has to be initialized before it is used.
10.Explain Jagged Arrays in C#?
If the elements of an array is an array then it’s called as jagged array. The elements can be of different sizes and dimensions.