.net - Generics and Enumerations -
how use(constraint) enumeration generic parameter in .net?
i used somthing like
public function getenumstringvalues(of etype {structure, _ icomparable, iconvertible, iformattable})() list(of string) but not good.
you can use enum types generic parameters method (for example list<etype>, cannot restrict generic parameters enum types.
however, there tricks can use almost guarantee enums used in methods:
public static t parseenum<t>(this string enumvalue) t : struct, iconvertible see converting string enum more full explanation , code samples.
Comments
Post a Comment