When we have use generics in project of .net? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

When we have use generics in project of .net?

2nd Feb 2017, 6:39 PM
Rohit Gadave
Rohit Gadave - avatar
2 Answers
+ 1
if u mean what for generics use for in .net it is use to type Safety , Performance And reuse code .
4th Feb 2017, 9:12 PM
Faisal Raufi
Faisal Raufi - avatar
+ 1
In modern C# you can't avoid generics and that is not a bad thing. Generics provide better run time safety. Generics prevents boxing and unboxing at run time so it is performant. Generics is reusable in the sense that if you have something "generic" that is type independent, you don't have to provide multiple versions of the same method or dare I say "copy and paste". The most common place you will see generics is IEnumerable (including any of its implementations).
7th Mar 2018, 1:14 PM
Greg R Taylor
Greg R Taylor - avatar