【发布时间】:2012-04-26 23:26:35
【问题描述】:
没有多重继承。但是我的项目伙伴使用接口来实现add, remove 等方法。
代码如下:
public interface IAccountCategoryDataSource
{
bool Add(AccountCategory accountCategory);
bool Update(AccountCategory accountCategory);
bool Remove(AccountCategory accountCategory);
AccountCategory GetById(int id);
AccountCategory GetByName(string name);
IEnumerable<AccountCategory> GetByParentCategory(AccountCategory category);
IEnumerable<AccountCategory> GetTopLevelCategories();
IEnumerable<AccountCategory> GetBySearchTerm(string searchTerm);
IEnumerable<AccountCategory> GetAll();
event EventHandler<ObjectAddedEventArgs> AccountCategoryAdded;
event EventHandler<ObjectUpdatedEventArgs> AccountCategoryUpdated;
event EventHandler<ObjectRemovedEventArgs> AccountCategoryRemoved;
}
请解释一下接口的需求。
【问题讨论】:
-
“多级继承”是什么意思?
-
我不明白你的问题。一个接口代表一个契约,在这里它很可能用于将契约与其实现分离。甚至可能在此接口的使用者未引用的程序集中实现。
-
据我所知,我只在多级继承的情况下使用接口。但是,在这里我没有看到任何多级继承的情况。所以,我无法理解接口的作用。
-
@user1334247:您还没有解释“多级继承”是什么意思。
-
@user1334247:好的 - 您应该知道“多级继承”不是实现多个接口的标准术语。并且大多数时候使用接口没有多个接口由同一类型实现。
标签: c# mvvm-light