C# - Do you use "var"?

Posted by Paul Stovell on Stack Overflow See other posts from Stack Overflow or by Paul Stovell
Published on 2009-03-11T05:44:12Z Indexed on 2010/05/16 11:00 UTC
Read the original article Hit count: 311

Filed under:
|

C# 3.0 introduces implicitly typed variables, aka the "var" keyword.

var daysInAWeek = 7;
var paul = FindPerson("Paul");
var result = null as IPerson;

Others have asked about what it does or what the problems with it are:

I am interested in some numbers - do you use it? If so, how do you use it?

  1. I never use var (and I never use anonymous types)
  2. I only use var for anonymous types
  3. I only use var where the type is obvious
  4. I use var all the time!

© Stack Overflow or respective owner

Related posts about c#

Related posts about discussion