当我第一次在类中实现接口时,我希望 resharper 6 或 Visual Studio 2010 将我的属性实现为自动实现的属性,而不是放入 throw new NonImplementedException(); 的默认值。我怎样才能做到这一点?例如:
public interface IEmployee
{
// want this to stay just like this when implemented into class
ID { get; set; }
}
public class Employee : IEmployee
{
// I do not want the throw new NonImplemented exception
// I want it to just appear as an auto implemented property
// as I defined it in the interface
public int ID
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
}
因为这种情况一直在发生,我发现自己不得不不断重构并手动删除那些抛出新的 UnImplimented() 异常并手动使属性自动实现......很痛苦!毕竟,我在我的界面中将它定义为一个自动实现的属性。
非常感谢任何帮助或建议!谢谢。