Answered by:
adding a value in enum programmatically ?

Question
-
Thanks for your attention and time,
Kindly guide how to add a value/ option in enum at run time programmatically.
Thanks in anticipation,
haansiSunday, October 18, 2009 5:56 PM
Answers
-
Try using a list object for the same functionality and you can manipulate that in runtime
Ganesh Ranganathan
[Please mark the post as answer if it answers your question]
blog.ganeshzone.net- Marked as answer by Haansi Monday, October 19, 2009 3:53 AM
Sunday, October 18, 2009 6:02 PM -
Rudy is right. And there is no point in doing so. An enum is very useful to declare a type-safe identifier instead of using a plain number. It makes the code much more readable and it helps you to avoid using the wrong number. But if you need to represent a value at runtime that you cannot declare up front then you should use a plain int.
Hans Passant.- Marked as answer by Haansi Monday, October 19, 2009 3:53 AM
Sunday, October 18, 2009 6:53 PM
All replies
-
You can cast an enum to most any integral value that you want.
But, you cannot add new items to the enumeration itself.
By definition, it is a constant.
The short is 'no', you cannot add to an enumeration at runtime.
Rudy =8^D
Mark the best replies as answers. "Fooling computers since 1971."- Proposed as answer by Wole Ogunremi Sunday, October 18, 2009 7:29 PM
Sunday, October 18, 2009 6:00 PM -
Try using a list object for the same functionality and you can manipulate that in runtime
Ganesh Ranganathan
[Please mark the post as answer if it answers your question]
blog.ganeshzone.net- Marked as answer by Haansi Monday, October 19, 2009 3:53 AM
Sunday, October 18, 2009 6:02 PM -
Rudy is right. And there is no point in doing so. An enum is very useful to declare a type-safe identifier instead of using a plain number. It makes the code much more readable and it helps you to avoid using the wrong number. But if you need to represent a value at runtime that you cannot declare up front then you should use a plain int.
Hans Passant.- Marked as answer by Haansi Monday, October 19, 2009 3:53 AM
Sunday, October 18, 2009 6:53 PM