【发布时间】:2014-08-26 20:08:20
【问题描述】:
我有以下界面..它有一个错误,我不知道为什么会发生。基本上对于接口部分string DoorDescription { get; private set; } 必须删除private set 才能使其工作
namespace test6
{
interface IHasExteriorDoor
{
string DoorDescription { get; private set; }
string DoorLocation { get; set; }
}
class Room : IHasExteriorDoor
{
public Room(string disc, string loc)
{
DoorDescription = disc;
DoorLocation = loc;
}
public string DoorDescription { get; private set; }
public string DoorLocation { get; set; }
}
class Program
{
static void Main(string[] args)
{
Room a = new Room("A","B");
a.DoorLocation = "alien";
//a.DoorDescription = "mars";
}
}
}
【问题讨论】:
-
@MitchWheat 我的问题是接口部分和类部分都使用
get;private set;为什么它不起作用..
标签: c#