c# - sourcecode problem at enum -
goal:
assign enum value animaltype object.
categories.categorytype animaltype = (categorytype)enum.parse(gettype(categorytype), pcategory);
problem: source code not work , gives me 2 error messages:
"assignment1.categories.categorytype' 'type' used 'variable'"
"no overload method 'gettype' takes 1 arguments"
namespace assignment1 { class animalmanager { private list<ianimal> _myanimal = new list<ianimal>(); public void createnewanimal(string pname, string phousing, string page, string pcategory, string panimal, string peater, string pgender) { categories.categorytype animaltype = (categorytype)enum.parse(gettype(categorytype), pcategory); } } }
using system; using system.collections.generic; using system.linq; using system.text; namespace assignment1.categories { /// <summary> /// /// </summary> public enum categorytype { mammal, bird, marine, reptile, insect } }
try this:
categories.categorytype animaltype = (categorytype)enum.parse(typeof(categorytype), pcategory);
Comments
Post a Comment