-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
  • 19,524
  • 23
  • 98
  • 161

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
  • 59,957
  • 7
  • 91
  • 109