What are the Advantages of Generics?

DWQA QuestionsCategory: C SharpWhat are the Advantages of Generics?
Editor Staff asked 11 months ago

What are the Advantages of Generics?

1 Answers
Editor Staff answered 11 months 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.