473,385 Members | 1,355 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.

how do you return a value for an enum property type?

Bob
It should be simple, but I'm stuck on this one... how do you return a value for
an enum property type?

TIA,
Bob

Nov 20 '05 #1
6 4805
"Bob" <no*****@nospam.net> schrieb
It should be simple, but I'm stuck on this one... how do you return a
value for an enum property type?


I'm not sure if this is what you are looking for:

Property MyProp() As FormBorderStyle
Get
Return FormBorderStyle.None
End Get
Set(ByVal Value As FormBorderStyle)

End Set
End Property

(the example doesn't make sense but it shows...)
--
Armin

http://learn.to/quote
http://www.plig.net/nnq/nquote.html

Nov 20 '05 #2
Bob
An example to clarify:

Public ReadOnly Property SomeEnum() As System.Enum
Get
'How do I return RandomEnum ???
End Get
End Property

Public Enum RandomEnum
member1
member2
End Enum

Bob

"Armin Zingler" <az*******@freenet.de> wrote in message
news:ey****************@TK2MSFTNGP12.phx.gbl...
"Bob" <no*****@nospam.net> schrieb
It should be simple, but I'm stuck on this one... how do you return a
value for an enum property type?


I'm not sure if this is what you are looking for:

Property MyProp() As FormBorderStyle
Get
Return FormBorderStyle.None
End Get
Set(ByVal Value As FormBorderStyle)

End Set
End Property

(the example doesn't make sense but it shows...)
--
Armin

http://learn.to/quote
http://www.plig.net/nnq/nquote.html


Nov 20 '05 #3
"Bob" <no*****@nospam.net> schrieb
An example to clarify:

Public ReadOnly Property SomeEnum() As System.Enum
Get
'How do I return RandomEnum ???
I don't know whether I understand your problem:

Return RandomEnum.member1

End Get
End Property

Public Enum RandomEnum
member1
member2
End Enum

But, why don't you declare the property this way?

Public ReadOnly Property SomeEnum() As RandomEnum

This also enables intellisense after typing "return "
--
Armin

http://learn.to/quote
http://www.plig.net/nnq/nquote.html

Nov 20 '05 #4
Bob
I don't want to return an Enum member. I want to return the Enum itself.

But I guess I'll be stuck with returning its type instead. Oh well.

Bob

"Armin Zingler" <az*******@freenet.de> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
"Bob" <no*****@nospam.net> schrieb
An example to clarify:

Public ReadOnly Property SomeEnum() As System.Enum
Get
'How do I return RandomEnum ???


I don't know whether I understand your problem:

Return RandomEnum.member1

End Get
End Property

Public Enum RandomEnum
member1
member2
End Enum

But, why don't you declare the property this way?

Public ReadOnly Property SomeEnum() As RandomEnum

This also enables intellisense after typing "return "
--
Armin

http://learn.to/quote
http://www.plig.net/nnq/nquote.html


Nov 20 '05 #5
Return RandomEnum.member1 will return 0
Return RandomEnum.member2 will return 1

You want to return the enum itself? You can refer to it's elements from the
class where you design it?

"Armin Zingler" <az*******@freenet.de> wrote in message
news:#E**************@TK2MSFTNGP11.phx.gbl...
"Bob" <no*****@nospam.net> schrieb
An example to clarify:

Public ReadOnly Property SomeEnum() As System.Enum
Get
'How do I return RandomEnum ???


I don't know whether I understand your problem:

Return RandomEnum.member1

End Get
End Property

Public Enum RandomEnum
member1
member2
End Enum

But, why don't you declare the property this way?

Public ReadOnly Property SomeEnum() As RandomEnum

This also enables intellisense after typing "return "
--
Armin

http://learn.to/quote
http://www.plig.net/nnq/nquote.html

Nov 20 '05 #6
"Bob" <no*****@nospam.net> schrieb
I don't want to return an Enum member. I want to return the Enum
itself.

But I guess I'll be stuck with returning its type instead. Oh
well.


The Enum itself *is* a type, so you can

Return GetType(RandomEnum)

and change the property type to "As System.Type"
--
Armin

http://learn.to/quote
http://www.plig.net/nnq/nquote.html

Nov 20 '05 #7

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

Similar topics

7
by: mcdonamw | last post by:
This may sound like a stupid stupid question and I figure it would b more "general" than pertaining to a specific Language. I'm using vb.net and I have a bunch of Const values in my program. can...
4
by: thechaosengine | last post by:
Hi all, I have a property called GeneralStatus that can return an int between -1 and 3. These values are represented by an enumeration called StatusEnum. My question is, should my property...
20
by: Glenn Venzke | last post by:
I'm writing a class with a method that will accept 1 of 3 items listed in an enum. Is it possible to pass the item name without the enum name in your calling statement? EXAMPLE: public enum...
4
by: Frank Rizzo | last post by:
I am being passed a string, such as ControlText. From this string, I must figure its color value and set that value to a control. All these values are stored in the System.Drawing.SystemColors.*...
3
by: Sanjay Pais | last post by:
I know that string/char enum is not possible in c# (.NET2.0) I need to create the equivalent of this: public enum HOW_GOOD { AWESOME = "A", GREAT= "G", NOT_TOO_BAD = "N", TERRIBLE="T" }
2
by: Robert W. | last post by:
In a posting earlier this year I found a simple approach to convert a string to a particular Enum value. The one line solution looked like this: MyEnum ConvertedString = (MyEnum)...
8
by: =?Utf-8?B?RG91Z2xhcyBNYXJxdWFyZHQ=?= | last post by:
Using VB.Net 2005. I have my interfaces and enums defined in a DLL. For example, I have this enum: Public Enum OpStatusTypes Normal InProgress Paused End Enum
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.