使用“var”會影響性能嗎? - Will using 'var' affect performance?

問題:

Earlier I asked a question about why I see so many examples use the var keyword and got the answer that while it is only necessary for anonymous types, that it is used nonetheless to make writing code 'quicker'/easier and 'just because'.早些時候我問了一個問題, 爲什麼我看到這麼多例子使用var關鍵字,並得到了答案,雖然它只對匿名類型是必需的,但它仍然用於使編寫代碼“更快”/更容易和“只是因爲”。

Following this link ("C# 3.0 - Var Isn't Objec") I saw that var gets compiled down to the correct type in the IL (you will see it about midway down article).按照 此鏈接(“C# 3.0 - Var 不是對象”),我看到var被編譯爲 IL 中的正確類型(您將在文章中途看到它)。

My question is how much more, if any, IL code does using the var keyword take, and would it be even close to having a measurable level on the performance of the code if it was used everywhere?我的問題是,如果有的話,IL 代碼使用var關鍵字的情況還有多少?


解決方案:

參考一: https://stackoom.com/question/1Upa
參考二: Will using 'var' affect performance?
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章