【发布时间】:2011-11-30 19:30:07
【问题描述】:
我的 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
}
【问题讨论】:
-
我认为你应该看一个抽象类,它更适合这些类型的东西。