Answer the question
In order to leave comments, you need to log in
Which is faster: var or explicit type declaration?
Which way is faster?
A a = new A();
var a = new A();
Answer the question
In order to leave comments, you need to log in
Equally.
var is an instruction to the compiler to determine the type itself, and this does not affect the runtime in any way.
Sometimes it will even be faster, because the variable will be of the most concrete type (and then you won’t have to box anything, and you won’t have to make virtual calls through the base class or interface)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question