Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static string GetEnumFlags(Type enumType)
- {
- //Type enumType = typeof(System.Diagnostics.TraceOptions);
- System.Text.StringBuilder builder = new System.Text.StringBuilder();
- int maxValue = 0;
- Array values = Enum.GetValues(enumType);
- for(int i=0;i<values.Length;i++){
- int v = Convert.ToInt32(values.GetValue(i));
- if(v> maxValue)
- maxValue = v;
- }
- maxValue *= 2;
- // Display all possible combinations of values.
- // Also display an invalid value.
- for( int val = 0; val <= maxValue; val++ )
- builder.AppendFormat( "{0,3} - {1}\r\n",
- val, (Enum.ToObject(enumType,val)).ToString( ) );
- return builder.ToString();
- }
Advertisement
Add Comment
Please, Sign In to add comment