Copyright © 2008-2016 Paula DiTallo

Tag Cloud

August 2010 Entries

Why did I get the error: Cannot implicitly convert type 'string' to 'yourEnumDef.type' in my C# program?

If you are working with enum types, you were probably trying to assign something like an input string to the constants you defined as an enum type earlier. let's say you created an enum type called PoliticianType enum PoliticianType { knownothing = 1000, whig = 1010, federalist = 1020, republican = 1030, democrat = 1040 } ...and you had a console app that was accepting user input from a readline statement: Console.Write("Which political party? (press CTRL+Z to exit): "); string political_party = ......