C#的行为"复制"道具

时间:2016-04-06 23:02:52

标签: c# properties interface

好吧,假设我有2个接口IBook,IJournal
除了一个不同的枚举之外,每个都具有相同的属性,例如:

public interface IBook
{
    //each Book Must have these parameters.
    BookCategory BookType { get; set; }
    string ItemName { get; set; }
    DateTime Time { get; set; }
    int Copynumber { get; set; }
}
public interface IJournal
{

    JournalCategory JournalType { get; set; }
    string ItemName { get; set; }
    DateTime Time { get; set; }
    int Copynumber { get; set; }
}

,名为AbstractItem的类使用它们:class AbstractItem:Ibook,IJournal
会发生什么?
我会有:

BookCategory BookType { get; set; }
JournalCategory JournalType { get; set; }
string ItemName { get; set; }
DateTime Time { get; set; }
int Copynumber { get; set; }


1 个答案:

答案 0 :(得分:0)

是的,这正是你将拥有的。你没试过吗?