Options for an Enum with reserved types

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ryan Taylor

    Options for an Enum with reserved types

    Hello.

    I have a quick and "simple" question that will probably boil down to opinion
    more than anything else. I need a FieldType property for a class I am
    writing. As such an Enum would be the perfect solution for this property. In
    C# I can write

    Public Enum FieldType
    Integer = 0
    Float
    Double
    String
    Date
    ObjectId
    End Enum

    And everything works like a charm. I have been requested to rewrite this in
    VB.NET. However, VB.NET is not case sensitive so that structure does not
    work because Interger, Double, String and Date are reserved types regardless
    of case. Is there a defined recommended alternative for this? Prefix or
    Suffix? What do you think about?

    Public Enum FieldType
    enumInteger = 0
    enumFloat
    enumDouble
    enumString
    enumDate
    enumObjectId
    End Enum

    or

    Public Enum FieldType
    _Integer = 0
    _Float
    _Double
    _String
    _Date
    _ObjectId
    End Enum


  • Herfried K. Wagner [MVP]

    #2
    Re: Options for an Enum with reserved types

    "Ryan Taylor" <rtaylor@stgeor geconsulting.co m> schrieb:[color=blue]
    > I need a FieldType property for a class I am writing. As such an Enum
    > would be the perfect solution for this property. In C# I can write
    >
    > Public Enum FieldType
    > Integer = 0
    > Float
    > Double
    > String
    > Date
    > ObjectId
    > End Enum
    >
    > And everything works like a charm. I have been requested to rewrite this
    > in VB.NET. However, VB.NET is not case sensitive so that structure does
    > not work because Interger, Double, String and Date are reserved types
    > regardless of case.[/color]

    Put the keywords between square brackets to escape them:

    \\\
    Public Enum FieldType
    [Integer] = 0
    Float
    [Double]
    ...
    End Enum
    ///

    --
    M S Herfried K. Wagner
    M V P <URL:http://dotnet.mvps.org/>
    V B <URL:http://classicvb.org/petition/>

    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: Options for an Enum with reserved types

      "Ryan Taylor" <rtaylor@stgeor geconsulting.co m> schrieb:[color=blue]
      > I need a FieldType property for a class I am writing. As such an Enum
      > would be the perfect solution for this property. In C# I can write
      >
      > Public Enum FieldType
      > Integer = 0
      > Float
      > Double
      > String
      > Date
      > ObjectId
      > End Enum
      >
      > And everything works like a charm. I have been requested to rewrite this
      > in VB.NET. However, VB.NET is not case sensitive so that structure does
      > not work because Interger, Double, String and Date are reserved types
      > regardless of case.[/color]

      Put the keywords between square brackets to escape them:

      \\\
      Public Enum FieldType
      [Integer] = 0
      Float
      [Double]
      ...
      End Enum
      ///

      --
      M S Herfried K. Wagner
      M V P <URL:http://dotnet.mvps.org/>
      V B <URL:http://classicvb.org/petition/>

      Comment

      • Carlos J. Quintero [VB MVP]

        #4
        Re: Options for an Enum with reserved types

        You can use parenthesis and it will work:

        Public Enum FieldType
        [Integer] = 0
        [Float]
        ....


        --

        Best regards,

        Carlos J. Quintero

        MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
        You can code, design and document much faster.
        Free resources for add-in developers:
        MZ-Tools has a single goal: To make your everyday programming life easier. As an add-in to several Integrated Development Environment (IDEs) from Microsoft, MZ-Tools adds new menus and toolbars to them that provide many new productivity features.


        "Ryan Taylor" <rtaylor@stgeor geconsulting.co m> escribió en el mensaje
        news:uqXIfM6tFH A.2568@TK2MSFTN GP15.phx.gbl...[color=blue]
        > Hello.
        >
        > I have a quick and "simple" question that will probably boil down to
        > opinion more than anything else. I need a FieldType property for a class I
        > am writing. As such an Enum would be the perfect solution for this
        > property. In C# I can write
        >
        > Public Enum FieldType
        > Integer = 0
        > Float
        > Double
        > String
        > Date
        > ObjectId
        > End Enum
        >
        > And everything works like a charm. I have been requested to rewrite this
        > in VB.NET. However, VB.NET is not case sensitive so that structure does
        > not work because Interger, Double, String and Date are reserved types
        > regardless of case. Is there a defined recommended alternative for this?
        > Prefix or Suffix? What do you think about?
        >
        > Public Enum FieldType
        > enumInteger = 0
        > enumFloat
        > enumDouble
        > enumString
        > enumDate
        > enumObjectId
        > End Enum
        >
        > or
        >
        > Public Enum FieldType
        > _Integer = 0
        > _Float
        > _Double
        > _String
        > _Date
        > _ObjectId
        > End Enum
        >[/color]


        Comment

        • Carlos J. Quintero [VB MVP]

          #5
          Re: Options for an Enum with reserved types

          You can use parenthesis and it will work:

          Public Enum FieldType
          [Integer] = 0
          [Float]
          ....


          --

          Best regards,

          Carlos J. Quintero

          MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
          You can code, design and document much faster.
          Free resources for add-in developers:
          MZ-Tools has a single goal: To make your everyday programming life easier. As an add-in to several Integrated Development Environment (IDEs) from Microsoft, MZ-Tools adds new menus and toolbars to them that provide many new productivity features.


          "Ryan Taylor" <rtaylor@stgeor geconsulting.co m> escribió en el mensaje
          news:uqXIfM6tFH A.2568@TK2MSFTN GP15.phx.gbl...[color=blue]
          > Hello.
          >
          > I have a quick and "simple" question that will probably boil down to
          > opinion more than anything else. I need a FieldType property for a class I
          > am writing. As such an Enum would be the perfect solution for this
          > property. In C# I can write
          >
          > Public Enum FieldType
          > Integer = 0
          > Float
          > Double
          > String
          > Date
          > ObjectId
          > End Enum
          >
          > And everything works like a charm. I have been requested to rewrite this
          > in VB.NET. However, VB.NET is not case sensitive so that structure does
          > not work because Interger, Double, String and Date are reserved types
          > regardless of case. Is there a defined recommended alternative for this?
          > Prefix or Suffix? What do you think about?
          >
          > Public Enum FieldType
          > enumInteger = 0
          > enumFloat
          > enumDouble
          > enumString
          > enumDate
          > enumObjectId
          > End Enum
          >
          > or
          >
          > Public Enum FieldType
          > _Integer = 0
          > _Float
          > _Double
          > _String
          > _Date
          > _ObjectId
          > End Enum
          >[/color]


          Comment

          • Ryan Taylor

            #6
            Re: Options for an Enum with reserved types

            Thanks guys!


            Comment

            • Ryan Taylor

              #7
              Re: Options for an Enum with reserved types

              Thanks guys!


              Comment

              Working...