I'm trying to assign a short to a enum like this:;
public enum ValueRepresentation : short
{
ApplicationEntity = short.Parse("AE"),
AgeString = short.Parse("AS")
}
This however, obviously, doesn't work. But is there a quick fix to make this work?
Cheers
No. Enum values are always compile-time constants. If you want them to be values created by running code, you'll have to autogenerate your source code.
(How exactly would parsing "AS" work anyway?)
Of course, another alternative is to not use enums. They may not be the most appropriate solution for what you're trying to do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With