Will using ‘var’ affect performance?

Earlier I asked a question about why I see so many examples use the varkeyword 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’.

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).

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?

12 Answers
12

Leave a Comment