473,499 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
Nov 21 '05 #1
6 1891
"Ryan Taylor" <rt*****@stgeorgeconsulting.com> schrieb:
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.


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/>

Nov 21 '05 #2
"Ryan Taylor" <rt*****@stgeorgeconsulting.com> schrieb:
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.


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/>

Nov 21 '05 #3
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:
http://www.mztools.com

"Ryan Taylor" <rt*****@stgeorgeconsulting.com> escribió en el mensaje
news:uq**************@TK2MSFTNGP15.phx.gbl...
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

Nov 21 '05 #4
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:
http://www.mztools.com

"Ryan Taylor" <rt*****@stgeorgeconsulting.com> escribió en el mensaje
news:uq**************@TK2MSFTNGP15.phx.gbl...
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

Nov 21 '05 #5
Thanks guys!
Nov 21 '05 #6
Thanks guys!
Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
37030
by: Alexander Grigoriev | last post by:
Not quite new version of GCC that I have to use, craps with the following code: enum E; enum E { e }; That is, it doesn't accept forward declaration of enum. C++ standard text doesn't...
0
1729
by: Vaclav Haisman | last post by:
Motivation: I have been working on some project recently that uses lots of enums with disjunctive intervals of values because it is rather convenient way to define series of constants with...
18
2342
by: Nebula | last post by:
Consider enum Side {Back,Front,Top,Bottom}; enum Side a; Now, why is a = 124; legal (well it really is an integer, but still, checking could be performed..) ? Wouldn't enums be more useful if...
31
3561
by: Michael C | last post by:
If a class inherits from another class, say Form inherits from control, then I can assign the Form to a variable of type Control without needing an explicit conversion, eg Form1 f = new Form1();...
4
5557
by: Martin Pritchard | last post by:
Hi, I'm working on a project that historically contains around 40 enums. In the database various fields refer to the int values of these enums, but of course ref integrity is not enofrced and...
0
256
by: Ryan Taylor | last post by:
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...
3
2908
by: VK | last post by:
Just to realease my frustration: innocent "enum" is a reserved word in JScript! !@#$%^&* I occasionally discovered it just before I got ready to smash my computer over my head (some people...
34
11129
by: Steven Nagy | last post by:
So I was needing some extra power from my enums and implemented the typesafe enum pattern. And it got me to thinking... why should I EVER use standard enums? There's now a nice little code...
12
6673
by: Cmtk Software | last post by:
I'm trying to define an enum which will be used from unmanaged c++, C++/CLI managed c++ and from C#. I defined the following enum in a VS dll project set to be compiled with the /clr switch: ...
0
7134
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7180
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6901
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7392
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4920
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3105
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3101
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
307
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.