C#中的多重继承
发布时间:2020-12-15 18:34:39 所属栏目:百科 来源:网络整理
导读:当我作为C#开发人员工作时,我知道我们可以通过使用Interface实现多重继承. 任何人都可以提供链接或代码,了解如何使用C#实现多重继承. 我想要使??用Interface在C#中实现多重继承的代码. 提前致谢. 解决方法 这是一个很好的例子. http://blog.vuscode.com/malo
当我作为C#开发人员工作时,我知道我们可以通过使用Interface实现多重继承.
任何人都可以提供链接或代码,了解如何使用C#实现多重继承. 我想要使??用Interface在C#中实现多重继承的代码. 提前致谢. 解决方法
这是一个很好的例子.
http://blog.vuscode.com/malovicn/archive/2006/10/20/How-to-do-multiple-inheritance-in-C_2300_-2D00-Implementation-over-delegation-_2800_IOD_2900_.aspx 快速代码预览: interface ICustomerCollection { void Add(string customerName); void Delete(string customerName); } class CustomerCollection : ICustomerCollection { public void Add(string customerName) { /*Customer collection add method specific code*/ } public void Delete(string customerName) { /*Customer collection delete method specific code*/ } } class MyUserControl: UserControl,ICustomerCollection { CustomerCollection _customerCollection=new CustomerCollection(); public void Add(string customerName) { _customerCollection.Add(customerName); } public void Delete(string customerName) { _customerCollection.Add(customerName); } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |