473,385 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 1889
"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
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
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
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
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
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
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
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
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
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
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.