Generics check with a feature in C# that lets in defining a Class or approach with kind as a Parameter.
Generics allow for designing a classes and strategies whose sorts are specified handiest on the time of assertion and instantiation. This enables development of well-known lessons and techniques that help in improving perFormance, productivity and type-safety.
Generics are often used in creating Collection training for enforcing ideas which include lists, hash Tables, Queues, etc. These classes manipulate a hard and fast of gadgets and encapsulate operations that aren't unique to a specific facts type.
Generics also are referred to as Parametric Polymorphism.
Generics had been introduced in C# 2.Zero as a part of Common Language Runtime of .NET to conquer the difficulty in imposing generalization in in advance versions. Generalization turned into done with the aid of Casting kinds to and from regular base kind, SySTEM.Object that cHanged into now not type-secure and required casting, which ends up in successful to overall performance.
Some of the benefits in the usage of generics consist of:
The List<T> series elegance is an example for frequent magNiFicence supplied in the .NET Framework Class Library that can be used to add, delete and seek an object of any kind (T) that is exceeded as parameter to it. When the List elegance is Instantiated with a type parameter in the client code, it would be similar to a concrete magnificence implemented with same kind.
Generics are just like C Templates in concept but Range especially in Implementation.
Your Score to Generics article
Score: 5 out of 5 (1 voters)
Be the first to comment on the Generics
tech-term.com© 2023 All rights reserved