阅读背景:

C#如何使用泛型类的泛型方法参数

来源:互联网 

So I have the following code:

所以我有以下代码:

public Dictionary<int, Class1<Class2>> someDictionary;

public T DoThings<T, U>(int id) where T : Class1<U>, new() where U : Class2, new()
{
    T something = null;
    if (!someDictionary.ContainsKey(id))
    {
        something = new T();
        someDictionary.Add(id, something);
    }
    return something;
}
pub



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: