Quando implemento un'interfaccia per la prima volta in una classe, desidero che sia il resharper 6 o lo studio visivo 2010 implementino le mie proprietà come proprietà implementate automaticamente e non inseriscano il valore predefinito di lanciare NonImplementedException() ;. Come posso fare questo? Per esempio:Come creare proprietà auto implementate quando si implementa un'interfaccia in una classe?
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();
}
}
}
Perché questo accade tutto il tempo, mi sto trovando a dover refactoring costantemente e rimuovere manualmente quelli gettare nuova UnImplimented) eccezioni (e manualmente rendono le proprietà siano automatica implementata ... un dolore! Dopotutto, l'ho definito come una proprietà auto implementata nella mia interfaccia.
Qualsiasi aiuto o consiglio molto apprezzato! Grazie.
Eventuali duplicati di http://stackoverflow.com/questions/3773312/change-the-implement-interface -template –