Array values = Enum.GetValues(typeof(Bar));
Random random = new Random();
Bar randomBar = (Bar)values.GetValue(random.Next(values.Length));
More Related Contents:
- How to declare enums in C#
- Enum “Inheritance”
- How to get C# Enum description from value? [duplicate]
- C# vs Java Enum (for those new to C#)
- Select N random elements from a List in C#
- Non-unique enum values
- Unique random string generation
- Produce a random number in a range using C#
- How to set enum to null
- C# Random Numbers aren’t being “random”
- Is there a way to check if int is legal enum in C#?
- Generating a Random Decimal in C#
- Enum.GetValues() Return Type
- How to convert a character in to equivalent System.Windows.Input.Key Enum value?
- How to define an enum with string value?
- Enum to Dictionary in C#
- How to prevent duplicate values in enum?
- Non-repetitive random number
- Binding an enum to a WinForms combo box, and then setting it
- Enum to Dictionary in C#
- Why does Random.Next() always return the same number [duplicate]
- How to convert from System.Enum to base integer?
- Pros and cons of RNGCryptoServiceProvider
- Multiple random numbers are the same [duplicate]
- C# Enum – How to Compare Value
- Using GetHashCode for getting Enum int value
- How to get random values from array in C# [duplicate]
- C# Select random element from List
- C# numeric enum value as string
- MVC 5.1 Razor DisplayFor not working with Enum DisplayName