Is their a way where the user could type Low to use the enum instead of typing 1?
I know how to do this with strings, but am having trouble trying to figure it out using enums.

public enum Volume : byte
{
    Low = 1,
    Medium,
    High
}

// shows different ways
// to work with enums
class Enumtricks
{
    static void Main(string[] args)
    {
        // instantiate type
        Enumtricks enumtricks = new Enumtricks();

        // demonstrates explicit cast
        // of int to Volume
        enumtricks.GetEnumFromUser();



        Console.ReadLine();
    }

Recommended Answers

All 2 Replies

Enum.TryParse()

Come on man, took me 10 seconds to Google ;)

commented: Sometimes you just need a little help finding it +1

Thanks, I was looking under enum switch, should have been looking for enum parse

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.