我试图让 Visual Studio 2015 (14.0) 在使用 C# 重构实现接口(interface)时使用自动属性。
即我想要这个;
public object SomeProperty { get; set; }
与此相反;
public object SomeProperty
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
我在过去版本的 Visual Studio 中通过编辑代码片段文件(说明 here)完成了此操作,但我无法使用 Visual Studio 2015 使其正常工作。
最佳答案
好的,所以我在测试 VS2019 Preview (16.0) 时偶然发现了答案。
在主菜单栏 Tools --> Options --> Text Editor --> C# --> Advanced
中寻找 Implement Interface or Abstract Class
选项生成属性时
选择首选自动属性
。
这会产生与用于处理 VS2015 之前的代码片段相同的结果。
关于c# - 使用自动属性 VS2015 重构 "Implement Interface",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32364335/