Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In C#, can I use reflection to determine if an enum type is int, byte, short, etc?

Tags:

c#

.net

types

enums

Is this possible? I can't find it anywhere.

like image 776
skb Avatar asked Feb 02 '09 16:02

skb


People also ask

What does |= mean in C?

The ' |= ' symbol is the bitwise OR assignment operator.

What is '~' in C programming?

In mathematics, the tilde often represents approximation, especially when used in duplicate, and is sometimes called the "equivalency sign." In regular expressions, the tilde is used as an operator in pattern matching, and in C programming, it is used as a bitwise operator representing a unary negation (i.e., "bitwise ...

What is operators in C?

An operator is a symbol that tells the compiler to perform specific mathematical or logical functions. C language is rich in built-in operators and provides the following types of operators − Arithmetic Operators.


1 Answers

Try this:

Enum.GetUnderlyingType(typeof(YourEnum)) 
like image 141
Andrew Hare Avatar answered Sep 20 '22 05:09

Andrew Hare