Foreach ( String S In Enum. getnames ( Typeof (Wallkind )))
{
Winformtools. msgbox (s );
}
Someone asked how to traverse the enumeration in revit API. traversing enumeration is the syntax function of C. From msdn
Enumeration can be used to store value pairs of strings and numbers, which is equivalent to a comparison table.
Common Methods: getname (), getvalue (), parse ()
Using System;
Public Class Enumtest {
Enum Days {Saturday, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday };
Enum Boilingpoints {Celcius = 100 , Fahrenheit = 212 };
[Flagsattribute]
Enum Colors {Red = 1 , Green = 2 , Blue = 4 , Yellow = 8 };
Public Static Void Main (){
Type weekdays = Typeof (Days );
Type boiling = Typeof (Boilingpoints );
Console. writeline ( " The days of the week, and their corresponding values in the days Enum are: " );
Foreach ( String S In Enum. getnames (Weekdays ))
Console. writeline ( " {0,-11 }={ 1} " , S, enum. Format (weekdays, enum. parse (weekdays, S ), " D " ));
Console. writeline ();
Console. writeline ( " Enums can also be created which have values that represent some meaningful amount. " );
Console. writeline ( " The boilingpoints Enum defines the following items, and corresponding values: " );
Foreach ( String S In Enum. getnames (boiling ))
Console. writeline ( " {0,-11 }={ 1} " , S, enum. Format (boiling, enum. parse (boiling, S ), " D " ));
Colors mycolors = colors. Red | colors. Blue | colors. Yellow;
Console. writeline ();
Console. writeline ( " Mycolors holds a combination of colors. Namely: {0} " , Mycolors );
}
}
URL: http://greatverve.cnblogs.com/archive/2012/06/06/Enum.html