What are the Advantages of Generics?

Category: C SharpWhat are the Advantages of Generics?
Editor">Editor Staff asked 2 years ago

What are the Advantages of Generics?

1 Answers
Editor">Editor Staff answered 2 years ago
  1. Generics increase the reusability of the code. You don’t need to write code to handle different data types.
  2. Generics are type-safe. You get compile-time errors if you try to use a different data type than the one specified in the definition.
  3. Generic has a performance advantage because it removes the possibilities of boxing and unboxing.