TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
ewalt
NA
5
0
Casting en enum to its underlying type.
Feb 2 2005 9:50 PM
Hey, this is kind of an obscure question... How do I cast (convert) an Enum of arbitrary type to its underlying type? I have a method that gets passed an Enum object (I don't know what type, other than it is an Enum), and the method needs to somehow convert that to an object of its underlying type. Thus, if it were passed en Enum whose type was byte and whose value was 5, then it would need to return a byte whose value was 5. If this is impossible, then how do I tell what the underlying type of an Enum is? Enum.GetType().GetElementType() does NOT work. Thanks for any help!
Reply
Answers (
7
)
C#: Excel Model Object
items to a custom combobox from an XML file and to display the progress of this in a progressbar