【发布时间】:2016-05-09 14:49:36
【问题描述】:
下面,当我尝试使用应该通过自动属性功能自动生成的 _currentTemp 变量时,我收到一条未找到变量的消息:
名称
_currentTemp在当前上下文中不存在。
使用{ get; set; } 应该会自动创建这个私有变量(_currentTemp),对吧?
public class DogTemperature
{
public double CurrentTemp { get; set; }
public DogTemperature(double dCurrentTemp)
{
_currentTemp = dCurrentTemp; //***this line***
}
}
【问题讨论】:
-
“应该是通过自动属性功能自动生成的” - 你能解释一下是什么让你这么想的吗?
标签: c# properties