What are generics in C#.NET?

What are generics in C#.NET?

Generic types to maximize code reuse, type safety, and performance.
They can be used to create collection classes.
Generic collection classes in the System.Collections.Generic namespace should be used instead of classes such as ArrayList in the System.Collections namespace.

What is C#.NET Generics?

The classes and the methods can treat the values of different types uniformly with the use if generics.

The usage of generics is advantageous as:

- They facilitate type safety
- They facilitate improved performance
- They facilitate reduced code
- They promote the usage of parameterized types
- The CLR compiles and stores information related to the generic types when they are instantiated. (The generic type instance refers to the location in memory of the reference type to which it is bound for all the instances of the generic type.)

Generics allow you to define type-safe data structures, without committing to actual data types. It allows writing less but more effective code. Generic provides flexibility and power but the developer needs to be responsible while using it.
Use of GetCommandLineArgs() method in C#.NET
What is the use of GetCommandLineArgs() method in C#.NET? - With GetCommandLineArgs() method, the command line arguments can be accessed...
What is the use of System.Environment class in C#.NET?
What is the use of System.Environment class in C#.NET? - The System.Environment class can be used to retrieve information...
Difference between const and readonly in C#.NET
What is the difference between const and readonly in C#.NET? - The read only can be modified by the class it is contained in...
Post your comment