Why should I use var instead of a type?

IAdapter picture IAdapter · Feb 1, 2011 · Viewed 125.6k times · Source

Possible Duplicate:
ReSharper and var

After I have installed ReSharper 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

Martin Buberl picture Martin Buberl · Feb 1, 2011

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

See also here for the performance question: