我有一个包含大量属性的类,这些属性包含一些计算结果,例如:
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
时类,Result3
将以红色突出显示,因为它尚未在 Results
中定义类。
目前我正在使用 Resharper ALT + Enter 快捷方式,选择“Create Property 'Result3'”,这将在 Results
中创建以下代码类:
public double Result3
{
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}
我需要手动更改为:
public double Result3 { get; set; }
然后我使用 CTRL + Shift + Backspace 快捷键返回 Calc
类。
如何在 Results
中轻松创建自动属性如果它们尚未直接从 Calc
中定义,则为类类(class)?
最佳答案
对于 Resharper 4/5,键入 prop
然后按 Tab 键,然后填写所需的参数。
关于c# - 使用 Visual Studio 2008/2010 或 Resharper 5 创建自动属性的快捷方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2974920/