寻找帮助将这样的结构组合在一起。 有基本的泛型类: public class A<T>
where T: class
{
public T info { get; set; }
} 适用于一步继承,例如: class B : A<BInfoClass>{} 但对于更高层次的成员需要相同的,但不需要使所有类都是泛型的: class C : B<CInfoClass>{} 需要为每个B、C、D等提供特定的"info“类型("info”类从一个基类派生):
说我有以下接口
using System;
public interface IInput
{
}
public interface IOutput<Shipper> where Shipper : IShipper
{
}
public interface IShipper
{
}
public interface IProvider<TInput, TOutput>
where TInput : IInput
where TOutput : IOutput<IShipper>
{
}
我能够创建以下类:
public c
简单课程:
class Pair<K,V> {
}
还有几项任务:
Collection<Pair<String,Long>> c1 = new ArrayList<Pair<String,Long>>();
Collection<Pair<String,Long>> c2 = c1; // ok
Collection<Pair<String,?>> c3 = c1; // this does not compile
Collection<? extends Pair<St
我试图在我的2D游戏引擎中实现一个fluent接口。
我的实现的简化示例:
public class Sprite<T> {
protected float x = 0.0;
protected float y = 0.0;
public T setPosition(float x, float y) {
this.x = x;
this.y = y;
return (T)this;
}
}
public class Living<T extends Living> extends