About me

Tuesday, September 29, 2015

Best C# Language Interview Questions and Answers

6. What is the difference between arrays and collection?


 1. You need to specify the size of an array at the time of its declaration. It cannot be resized dynamically.

2. The members of an array should be of the same data type.


1. The size of a collection can be adjusted dynamically, as per the user's requirement.
It does not have fixed size.
2. Collection can have elements of different types.

 7. What are collections and generics?

 A collection is considered as a group of related items that can be referred to as a single unit. The System.Collections namespace provides you with many classes and interfaces. Some of them are - ArrayList,List, Stack, ICollection, IEnumerable, and IDictionary. Generics provide the type-safety to your class at the compile time.When you create a data structure, you never need to specify the data type at the time of declaration. The System.Collections.Generic namespace contains all the generic collections.

8. How can you prevent your class to be inherited further?

You can prevent a class from being inherited further by defining it with the sealed keyword.

9. What is the index value of the first element in an array?

In an array, the index value of the first element is 0 (zero).

 10. Can you specify the accessibility modifier for methods inside the interface?

All the methods inside an interface are always public, by default. You cannot specify any other access modifier for them.

No comments:

Post a Comment