【发布时间】:2013-01-19 03:48:07
【问题描述】:
可能重复:
What is the best way to access properties from the same class, via accessors or directly?
我还在学习 C#。无论如何,我有一个简单的问题,但我不确定这样做的正常方法。假设我在课堂上有以下内容
private int _questionNo;
public int QuestionNo
{
get
{
return _questionNo;
}
private set
{
_questionNo = value;
PropChanged("QuestionNo");
}
}
如果我想在类本身中设置属性,我应该使用
_questionNo = number;
或
QuestionNo = number;
【问题讨论】:
标签: c# oop class properties