| |||
![]()
|
![]() ![]() |
![]()
А ларчик просто открывался: Народ задается вопросом "Why class fields [in C#] cannot be var?" (в смысле почему нельзя писать public var list = new List В ответах выдается масса умнософии типа: because you can't use var out of a method. You can't declare a global var and since constructors are also methods, you don't get the error В общем все выдумывают умные причины, почему это нельзя вставить в язык. А ларчик открывается просто: http://blogs.msdn.com/b/ericlippert/arc You'd think this would be straightforward; we could just take the code that we use to determine the type of a local variable declaration and use it on a field. Unfortunately, it is not nearly that easy. Doing so would actually require a deep re-architecture of the compiler. Короче - "ну не смогли мы это с ходу в транслятор вставить" Кстати - очень частая ситуация, когда довольно случайные технические решения стараниями "умников" возводятся в философию :) |
||||||||||||||
![]() |
![]() |