.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

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -