내 IVehicle 인터페이스에 Color라는 속성이 있습니다. 해당 인터페이스를 구현하는 모든 차량에 기본 색상 "빨간색"을 지정하려면 어떻게해야합니까? 다른 레벨이 필요합니까?인터페이스를 구현하는 모든 객체에서 속성의 기본값을 설정하는 방법은 무엇입니까?
public interface IVehicle
{
string Color { get; set; }
void Go();
void Stop();
}
public class Bmw : IVehicle
{
#region IVehicle Members
public string Color
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public void Go()
{
}
public void Stop()
{
}
#endregion
}
나는 당신이 이러한 유형의 것들에 더 적합한 추상 클래스를 봐야한다고 생각한다. –