Category Archives: enums

List colors in WPF and C#

This example shows how to list colors and display color samples in a WPF ListBox. To build the list, the example demonstrates reflection, LINQ, and XAML data templates. The program uses the following XAML code to define the ListBox that … Continue reading

Posted in drawing, enums, graphics, LINQ, reflection, wpf, XAML | Tagged , , , , , , , , , , , , , , , , , , , , , , | Leave a comment

Convert enum values to and from strings in C#

The System.Enum class provides several methods that convert enum values to and from strings. Some particularly useful methods include: GetName Returns the string name of an enum value. GetNames Returns an array of strings holding the names of an enum‘s … Continue reading

Posted in enums, syntax | Tagged , , , , , , , , , , , , | 3 Comments

Use reflection to enumerate HatchStyle values and display samples of them in C#

The post Use reflection to easily list the values defined by an enumerated type in C# shows one way to list the values in an enumeration. This example uses that technique in the following code to enumerate the HatchStyle values. … Continue reading

Posted in enums, graphics, reflection, syntax | Tagged , , , , , , , , , , | 2 Comments

Use reflection to easily list the values defined by an enumerated type in C#

The example Use reflection to list the values defined by an enum in C# shows one way to list the values defined by an enumerated type. That method is flexible but somewhat awkward. This example uses the first technique to … Continue reading

Posted in enums, reflection, syntax | Tagged , , , , , , , , , , | 1 Comment

Use reflection to list the values defined by an enum in C#

Reflection is an advanced technique that lets a program query objects about themselves. For example, it lets you learn what properties, methods, and events an object provides. This example shows how you can use it to list the values defined … Continue reading

Posted in enums, reflection, syntax | Tagged , , , , , , , , , , | 2 Comments