Which statement about the var keyword in C# is true?
Correct answer B. The type is inferred at compile time and the variable stays strongly typed
var asks the compiler to infer the variable's type from its initialiser, so var n = 10; makes n an int for good; assigning a string later is a compile error. It is only allowed for local variables and needs an initialiser. Behaviour that defers type checks to run time belongs to dynamic, not var, and fields must declare their type explicitly.
Answer checked How we write and check questions
Discussion