- foreach (MyEnum elementOfMyEnum in Enum.GetValues(typeof(MyEnum)))// go through all elements of a enum
- if (name.Contains(elementOfMyEnum.ToString()))// get the name of element and check if it's contained in name
- index = (int)elementOfMyEnum;//found an element which fit to the name