471,339 Members | 1,387 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Character equivalent of elements in an Enumeration

I have an enumeration as follows

Public Enum Delimiters
Tab
Semicolon
Comma
Space
End Enum

How can I return character equivalent of the elements in the enumeration?

Should I write a Function which checks each element and return character
equivalent or is there any other way as well?

Thanks

Jul 21 '05 #1
2 1943
Job,

You use the enum while you are programming, what is the goal you want to
reach with this enum.

Cor
Jul 21 '05 #2
Job,
Normally when I need character constants I use character constants instead
of an Enum.

Something like:

Public Notinheritable Class Delimiters

Const Tab As Char = ControlChars.Tab
Const Semicolon As char = ";"c
Const Comma As Char = ","c
Const Space As Char = " "c

Private Sub New()
End Sub

End Class

The "Notinheritable" prevents any one from inheriting from this class, the
"Private Sub New" prevents any one from instantiating this class.

NOTE: I normally put the above in the class where they are needed, not in
their own class...

If I "really" needed/wanted an Enum, I would consider using the AscW code of
the characters then use ChrW to get Characters out. However! I would
seriously consider the above constants first!

Something like:

Public Enum Delimiters

Tab = AscW(ControlChars.Tab)
Semicolon = AscW(";"c)
Comma = AscW(","c)
Space = AscW(" "c)

End enum

Dim ch As Char = ChrW(Delimiters.Tab)
Hope this helps
Jay

"Job Lot" <Jo****@discussions.microsoft.com> wrote in message
news:3A**********************************@microsof t.com...
|I have an enumeration as follows
|
| Public Enum Delimiters
| Tab
| Semicolon
| Comma
| Space
| End Enum
|
| How can I return character equivalent of the elements in the enumeration?
|
| Should I write a Function which checks each element and return character
| equivalent or is there any other way as well?
|
| Thanks
|
Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by kamp | last post: by
6 posts views Thread by Claude Henchoz | last post: by
8 posts views Thread by Mark P | last post: by
reply views Thread by rosydwin | last post: by

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.