Asa*_*sad 20 .net c# struct field
考虑这个代码块:
struct Animal
{
public string name = ""; // Error
public static int weight = 20; // OK
// initialize the non-static field here
public void FuncToInitializeName()
{
name = ""; // Now correct
}
}
Run Code Online (Sandbox Code Playgroud)
static
结构中的non-static
字段而不是字段?non-static
在方法体中初始化?