Pon*_*dum 23 .net c# parameters interface
是否可以定义一个接受必须实现两个接口的参数的函数?
(这两个界面是我刚想到的那个界面;不是我想要使用的界面)
private void DoSomthing(IComparable, ICollection input)
{
}
Run Code Online (Sandbox Code Playgroud)
Ken*_*art 54
您可以:
1)定义一个继承所需接口的接口:
public interface ICombinedInterface : IComparable, ICollection {... }
private void DoSomething(ICombinedInterface input) {... }
Run Code Online (Sandbox Code Playgroud)
2)使用泛型:
private void DoSomething<T>(T input)
where T : IComparable, ICollection
{...}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4400 次 |
| 最近记录: |