Generics: Why can't the compiler infer the type arguments in this case?

前端 未结 3 2054
忘掉有多难
忘掉有多难 2020-11-30 13:54

I wanted to write an extension-method that would work on dictionaries whose values were some sort of sequence. Unfortunately, the compiler can\'t seem to infer the generic a

3条回答
  •  醉话见心
    2020-11-30 14:39

    Why not leave out the type of the IEnumerable?

    public static void SomeMethod
    (this IDictionary dict)
    where TValue : IEnumerable { }    
    

提交回复
热议问题