Using VB Keywords In An Enum Statement

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nathan Sokalski

    #1

    Using VB Keywords In An Enum Statement

    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
    njsokalski@hotm ail.com
    有声小说网为广大读者提供热门小说在线免费阅读,本站收集的网络文学小说情节跌宕起伏,有声小说网是值得书友们收藏的小说在线阅读网。



  • Jay B. Harlow [MVP - Outlook]

    #2
    Re: Using VB Keywords In An Enum Statement

    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/de...fVBSpec2_2.asp

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


    "Nathan Sokalski" <njsokalski@hot mail.com> wrote in message
    news:uimsGlr0FH A.908@tk2msftng p13.phx.gbl...
    |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
    | njsokalski@hotm ail.com
    | http://www.nathansokalski.com/
    |
    |


    Comment

    Working...