【问题标题】:Any generic in C# (See code) [duplicate]C# 中的任何泛型(参见代码)[重复]
【发布时间】:2010-11-23 16:50:48
【问题描述】:

可能重复:
What is the equivalent of java wildcards in C# generics

我在一个 java 项目中注意到了这段代码:

public interface IClientFactory<T extends MMOClient<?>>

什么相当于接受 .NET/C# 中的任何泛型?

【问题讨论】:

  • 大概是这样的:public interface IClientFactory&lt;T,U&gt; where T : MMOClient&lt;U&gt;
  • @Gabe,我同意,或者只是制作 MMOClient 的“接口版本”,这样你就可以做到,where T : IMMOClient

标签: c# java .net generics


【解决方案1】:
public interface IClientFactory<T, TClient> where T : MMOClient<TClient>

【讨论】:

  • 但是在 OP 的问题中,MMOClient itself 接受了通用参数,所以你的答案是行不通的。
猜你喜欢
  • 2011-04-16
  • 2020-08-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-05-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多