我有一个类,其中包含大量属性,这些属性包含某些计算结果,例如:
public class Results
{
public double Result1 { get; set; }
public double Result2 { get; set; }
}
在另一个类中,我正在进行计算以填充上述属性,例如:
public class Calc
{
private Results Calc()
{
Results res = new Results();
res.Result1 = ... some calculation
res.Result2 = ... some other calculation
res.Result3 = ... // not yet defined in 'Results' class
return res;
}
}
当我编写
Calc
类时,Results
类中未定义的Result3
将以红色突出显示。目前,我使用Resharper的ALT+Enter快捷键,选择“创建属性'Result3'”,这将在
Results
类中创建以下代码:public double Result3
{
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}
我需要手动更改为:
public double Result3 { get; set; }
然后我使用 CTRL + Shift + Backspace 快捷键返回到 Calc
类。
如果还没有从 Calc
类直接定义,那么我该如何轻松地在 Results
类中创建自动属性?
prop
快捷方式似乎可以在 VS.NET 2010 中本地工作,而无需使用 Resharper 来创建自动属性。 - atconway