Hello experts,
I wonder why var is not allowed to be used in class level members. When using so, I am getting error as "The contextual keyword 'var' may only appear within a local variable declaration or in script code"
class ConcurrentDictionaryDemo
{
var phoneOrders = new ConcurrentDictionary(); //Error
{
var phoneOrders = new ConcurrentDictionary
............
............
}
Any thoughts on this?


Ehsan SajjadRank #512 · 4.8K reputationPosted Jul 3, 2016, 1:21 AM EDT
http://blogs.msdn.com/b/ericlippert/archive/2009/01/26/why-no-var-on-fields.aspx
Prakash TripathiRank #72 · 25.3K reputationPosted Jul 3, 2016, 10:59 AM EDT