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: 337
c#
|discussion
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:
- http://stackoverflow.com/questions/527685/anonymous-types-vs-local-variables-when-should-one-be-used
- http://stackoverflow.com/questions/209199/whats-the-point-of-the-var-keyword
- http://stackoverflow.com/questions/41479/use-of-var-keyword-in-c
I am interested in some numbers - do you use it? If so, how do you use it?
- I never use
var
(and I never use anonymous types) - I only use
var
for anonymous types - I only use
var
where the type is obvious - I use
var
all the time!
© Stack Overflow or respective owner