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

两盒软妹~` 提交于 2019-12-18 07:36:29

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/2771485/var-in-c-sharp-why-cant-it-be-used-as-a-member-variable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!