编译器警告(等级 4)CS0649
从未对字段“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()
{
}
}
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈