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

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -