Do C# Generics Have a Performance Benefit?

前端 未结 12 1142
感动是毒
感动是毒 2020-12-13 04:26

I have a number of data classes representing various entities.

Which is better: writing a generic class (say, to print or output XML) using generics and interfaces,

12条回答
  •  渐次进展
    2020-12-13 04:45

    There's a significant performance benefit to using generics -- you do away with boxing and unboxing. Compared with developing your own classes, it's a coin toss (with one side of the coin weighted more than the other). Roll your own only if you think you can out-perform the authors of the framework.

提交回复
热议问题