I ahve a combo whose source is an Enum. Now , among the other values(say value1, value2
etc.) there is one item Changes(%) that will be displayed in the combo .
How to define Changes(%) in the enum?
Using C#3.0
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t. Enum value names have to be valid C# identifiers. You shouldn’t be trying to put display names in there.
Instead, consider decorating each value with a
[Description]attribute which you can fetch with reflection:Alternatively define resources, possibly using the enum value name as the resource key. This will be better for i18n purposes, apart from anything else, although more work if you don’t need your app to be internationalized.
EDIT: Here’s a WayBack machine archive of an article going into more detail.