Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我改变了这个:
List<string> chapterNames = new List<string>();
...对此:
var chapterNames = new List<string>();
...并被编译器发出的这条消息猛烈抨击:
"上下文关键字 'var' 只能出现在局部变量声明中"
答案很简单,因为这就是 Microsoft 在 .NET 3.0 规范中引入 var 关键字的方式。
http://msdn.microsoft.com/en-us/library/bb384061.aspx