[英]analog of java wildcard (generic type) in c #
I rewrite the code with java on .net c # confronted with the problem of transfer classes with wildcard. 我在.net c#上用java重写了代码,但遇到了通配符传输类的问题。 There are two classes
有两节课
public abstract class Client <T extends Connection <? >>
public class Connection <T extends Client <? >>
I thought we could have done so 我以为我们可以这样做
public abstract class Client <T> where Connection <U>
but it turned out that even here does not work 但事实证明,即使在这里也不起作用
public abstract class Client <T, U> where Connection <T, U>
public abstract class Connection <T, U> where Client <T, U>
so how to get out of the situation? 那么如何摆脱困境呢?
You can do the following: 您可以执行以下操作:
public class Connection<T>
{
}
public abstract class Client<T, U> where T : Connection<U>
{
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.