Here's a very simple way to enumerate an enumeration:
enum UserAttributes {alias, cn, co, companyname, country, displayname}
foreach (UserAttributes enumValue in Enum.GetValues(typeof(UserAttributes)))
{
Console.WriteLine(enumValue.ToString());
}
I use enums a lot with command-line utilities and this is useful for putting together a cleaner, smaller "displaySyntax" function.
Monday, January 26, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment