Skip to content

Instantly share code, notes, and snippets.

@ninnemana
Created August 30, 2012 14:19
Show Gist options
  • Save ninnemana/3529450 to your computer and use it in GitHub Desktop.
Save ninnemana/3529450 to your computer and use it in GitHub Desktop.
Enum Casting from Form field
public class IndexController : Controller {
public void Index() {
string form_value = "Change";
Item i = new Item();
i.MaterialCode = (MatCode)Enum.Parse(typeof(MatCode), form_value);
}
}
public class Item {
public MatCode MaterialCode = new MatCode();
}
public enum MatCode{
A = "Add",
C = "Change"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment