Using VB Keywords In An Enum Statement

  • Thread starter Thread starter Nathan Sokalski
  • Start date Start date
N

Nathan Sokalski

I am creating an enumeration that is very similar to the DayNameFormat
enumeration. The 5 members I want are None, Full, Short, FirstLetter, and
FirstTwoLetters. Because Short is a VB.NET keyword, I am recieving an error
when creating the enumeration. My code is currently as follows:

Public Enum DayNameStyle
None
Full
Short
FirstLetter
FirstTwoLetters
End Enum

I know that there must be some way to avoid this error (they must have done
it somehow when creating DayNameFormat, and I am assuming the VB.NET
creators must have thought of this when creating VB.NET. Any ideas? Thanks.
 
Nathan,
You need to escape the identifiers in [], something like:

Public Enum DayNameStyle
None
Full
[Short]
FirstLetter
FirstTwoLetters
End Enum

For details on escapied identifiers see:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbls7/html/vblrfVBSpec2_2.asp

--
Hope this helps
Jay [MVP - Outlook]
T.S. Bradley - http://www.tsbradley.net


|I am creating an enumeration that is very similar to the DayNameFormat
| enumeration. The 5 members I want are None, Full, Short, FirstLetter, and
| FirstTwoLetters. Because Short is a VB.NET keyword, I am recieving an
error
| when creating the enumeration. My code is currently as follows:
|
| Public Enum DayNameStyle
| None
| Full
| Short
| FirstLetter
| FirstTwoLetters
| End Enum
|
| I know that there must be some way to avoid this error (they must have
done
| it somehow when creating DayNameFormat, and I am assuming the VB.NET
| creators must have thought of this when creating VB.NET. Any ideas?
Thanks.
| --
| Nathan Sokalski
| (e-mail address removed)
| http://www.nathansokalski.com/
|
|
 
Back
Top