|
-
Mar 12th, 2003, 07:09 AM
#1
Thread Starter
New Member
Enum or something else..??
Hi (first sorry for my bad english)
i have follow code:
VB Code:
Public Const COMPANY_TABLE As String = "Company"
Public Const COMPID_FIELD As String = "CompID"
Public Const COMPANYNAME_FIELD As String = "Companyname"
Public Enum FIELDS
COMPID_FIELD
COMPANYNAME_FIELD
End Enum
now, i would like to get back for example the COMPANYNAME_FIELD Value.
dim CompanyField as String = FIELDS.COMPANYNAME_FIELD
CompanyField should be now "Companyname"
I just want to list the possible fields in the .NET Environment
( public sub myFunction(byval Field as FIELDS) )
Maybe there is another way how to do this?
Last edited by RRDejaVu; Mar 12th, 2003 at 07:18 AM.
-
Mar 12th, 2003, 10:34 AM
#2
Member
If I understand the question correctly, the static GetValues() member of the enum type will return a string array, containg the enum item(s).
Code:
using System;
class ListEnum {
public enum Day {
Morning,
Afternoon,
Evening
}
static void Main() {
string[] enums = Enum.GetNames(typeof(Day));
foreach(string e in enums) {
Console.WriteLine(e);
}
}
}
The code is in C#, but you can use the same logic for VB.NET.[
Last edited by SimonVega; Mar 12th, 2003 at 10:56 AM.
AKA 'Lethal'
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|