Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

var in C# - Why can't it be used as a member variable? [duplicate]

Why is it not possible to have implicitly-typed variables at a class level within C# for when these variables are immediately assigned?

ie:

public class TheClass
{
    private var aList = new List<string>();
}

Is it just something that hasn't been implemented or is there a conceptual/technical reason for why it hasn't been done?

like image 677
David Neale Avatar asked May 05 '10 08:05

David Neale


1 Answers

Here's a blog post from Eric that explains the reasoning.

like image 99
Dean Harding Avatar answered Sep 19 '22 20:09

Dean Harding