C# - How to convert/parse a string to an enum

Are you looking for a way to parse a string to an enum? Below is an example of how you can easily do this. You can use the Enum.Parse method.

var vehicle = (Vehicle)Enum.Parse(typeof(Vehicle), "Bus"); 

public enum Vehicle
{
    Car,
    Bus,
    Boat,
    Plane
}