Iterating through an enumeration in Silverlight? -
In the Net in
iterate through the enumeration using System.Enum It is possible
or
System.Enum.GetValues (typeF (MyEnum))
P > In Silverlight 3, however, Enum.GetNames and Enum.GetValues are not defined Do anyone know any alternate?
Or perhaps using robust linq, like this:
< Code> public stable t [] GetEnumValues & lt; T & gt; () {Var type = typef (t); If (! Type.IsEnum) leave the new logic exception ("type" "+ type .name +" 'is not an enum'); Return (in the field in the field.Getfield (compulsive PLAZ.Public | binding flag.static) where field.Isilateral Selection (T) field.Gate value (empty)) .ORA (); } Public stable string [] GetEnumStrings & lt; T & gt; () {Var type = typef (t); If (! Type.IsEnum) leave the new logic exception ("type" "+ type .name +" 'is not an enum'); Return (by type in field.Getfield (BindingFlag.Public | Compulsive Flags.Static) where field. Choose ISILayer Field .name) .Oir (); }
Comments
Post a Comment