IAdapter IAdapter - 1 month ago 6
C# Question

Why should I use var instead of a type?


Possible Duplicate:

ReSharper and var




After I have installed ReShaper it demands(by warnings) that I use var whenever possible, for example

UnhandledExceptionEventArgs ue = (UnhandledExceptionEventArgs) t;


ReSharper wants to turn it into

var ue = (UnhandledExceptionEventArgs) t;


I like the first version better, is there any reason to prefer var? better performance? anything? or is it just a code style?

Answer

It's really just a coding style. The compiler generates the exact same for both variants.

See also here for the performance question: