对象类型的性能

问题描述:

对象类型在性能方面的代价是多少?

我应该尽量避免类型转换吗?

How costly is Object Typecasting in terms of performance?
Should I try to avoid Typecasting when possible?

它足够便宜,属于过早优化的范畴。不要浪费时间甚至思考或提出问题,除非你已经剖析你的应用程序,并确定这是一个问题,最重要的是:不要妥协你的设计,以避免它。

It is cheap enough that it falls into the category of premature optimization. Don't waste time even thinking or asking questions about it unless you have profiled your application and determined that it's a problem, and most importantly: don't compromise your design to avoid it.