string strName = \"John\"; public enum Name { John,Peter } private void DoSomething(string myname) { case1: if(myname.Equals(Name.John) //returns false {
For some reason, the given solutions didn't workout for me. I had to do in a slighly different way:
Name myName; if (Enum.TryParse(nameString, out myName)) { switch (myName) { case John: ... } }
Hope it helps someone :)