понедельник, 27 июля 2009 г.

overVARing

I hate such code:

var commandLine = SomeClass.SomeProperty;
var splitCommandLine = SomeClass.SomeMethod();

It tells nothing about the types of the variables.
Using var keyword is tolerable when you explicitly pronounce the type of the expression on the right side of the assignment or when the contract (your expectations) of the variable is important, but not its exact type.

var logger = new FastLogger();
var amout = Convert.ToInt32(input);
var logger = (ILogger)state; //or as ILogger
var query = from person in db.Persons where person.Age > 65 select person;

Комментариев нет:

Отправить комментарий