Do redundant casts get optimized?

前端 未结 4 873
死守一世寂寞
死守一世寂寞 2020-12-30 18:35

I am updating some old code, and have found several instances where the same object is being cast repeatedly each time one of its properties or methods needs to be called. E

4条回答
  •  Happy的楠姐
    2020-12-30 19:15

    No; FxCop flags this as a performance warning. See info here: http://msdn.microsoft.com/en-us/library/ms182271.aspx

    I'd recommend running that over your code if you want to find things to fix.

提交回复
热议问题