What are Generics?

 Posted by Poster on 9/12/2010 | Category: C# Interview questions | Views: 4662 | Points: 40

Generics means parametrized types. A class, structure, interface, delegates that operates on a parametrized type is called generics.

The ability to create type-safe code in which type-mismatch errors are caught at compile time rather than run time is the key advantage of the Generics. So using generics on the class, interface, methods or delegates avoids run time errors as it is caught at the compile time itself.

In order to use Generics, we need to work with System.Collections.Generic namespace.

IList<>, IEnumerable, IEnuerator<>, IComparer<>, ICollection<> and IDictionary are some of the frequently used generics objects.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response