更新:2007 年 11 月
错误消息
从未对字段“field”赋值,字段将一直保持其默认值“value”编译器检测到未初始化且从未被赋值的私有字段声明或内部字段声明。
下面的示例生成 CS0649:
![]() | |
---|---|
// CS0649.cs // compile with: /W:4 using System.Collections; class MyClass { Hashtable table; // CS0649 // You may have intended to initialize the variable to null // Hashtable table = null; // Or you may have meant to create an object here // Hashtable table = new Hashtable(); public void Func(object o, string p) { // Or here // table = new Hashtable(); table[p] = o; } public static void Main() { } } |