IAdapter IAdapter - 5 months ago 26
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?


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

See also here for the performance question: