-1

Trying to mimic this post: Create Generic method constraining T to an Enum

public static string[] ToTextArray(this Dictionary<string, T> dictionary) where T:struct, IConvertible
{
    ...
}

It appears my T cannot be resolved. What is the correct way to write an extension method for all Dictionary<string, enum_type> classes?

Community
  • 1
  • 1
Blaise
  • 21,314
  • 28
  • 108
  • 169

1 Answers1

7

You're missing the generic type parameter in the method declaration:

public static string[] ToTextArray<T>(this Dictionary<string, T> dictionary) 
  where T: struct, IConvertible
Luaan
  • 62,244
  • 7
  • 97
  • 116