knowcolor enumeration

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When I use the following C# code:

string [] colorNames = Enum.GetNames(typeof(KnownColor));

colorNames does not contain the full list of member names detailed in the
System.Drawing.KnownColor enumeration, but just a subset. Why is this?

Paul.
 
colorNames does not contain the full list of member names detailed in the
System.Drawing.KnownColor enumeration, but just a subset. Why is this?

It does here. Which ones are missing? It's not the fact that the list
of names ins't sorted that's confusing you, is it?



Mattias
 
Yes you are right. I was running an example program from the book 'Visual
C#.NET core reference' by Mickey Williams. The example used an up/down
control to cylcle through the KnownColor enumeration, setting the form's
background colour to each of the members. However, upon reaching the
'Transparent' member an exception was generated, as this is not a valid
background colour. I mistakenly assumed that the enumeration would be in the
same order as that specified in the MSDN library. As you pointed out, it is
not.

Thank you.
 
Back
Top