1

I have an assembly file that defines an enum as the following:

public enum DataType{  
    @byte,  
    @short,  
    @int,  
    @long,
    ...  
}  

When I get its names by calling the typeof(DataType).GetEnumNames() or Enum.GetNames(typeof(DataType)) methods, I will get the following string literals:
["byte", "short", "int", "long", ...].
How can I get the exact name of the elements?
Is there any mistake in naming the enum elements?

Hamid62
  • 183
  • 4
  • 15
  • 1
    Those are exact names. You can read more http://stackoverflow.com/questions/91817/whats-the-use-meaning-of-the-character-in-variable-names-in-c. – Dovydas Šopa Sep 11 '16 at 08:07

1 Answers1

2

You actually got the correct name for those fields in the enum. As stated in MSDN:

Keywords are predefined, reserved identifiers that have special meanings to the compiler. They cannot be used as identifiers in your program unless they include @ as a prefix. For example, @if is a valid identifier but if is not because if is a keyword.1

WelsonJR
  • 299
  • 3
  • 5