我想知道,当你创建一个自动属性 并调用在main()
方法set
一个随机值,其中该存储是value
?
如本例:自动属性
class Program
{
static void Main(string[] args)
{
Example W = new Example();
W.Num = 10;
Console.WriteLine("{0}", W.Num);
Console.WriteLine("{0}", W.getNum());
}
}
class Example
{
private int num;
public int Num { get; set; }
public int getNum() { return num; }
}
为什么是输出:
这就是从我身上遗失的^^。 非常感谢,现在我明白了 – Moutasem