|
-
May 5th, 2004, 11:16 AM
#1
Thread Starter
Addicted Member
Can you For Each an Enumerator?
I'm not sure if this is possible or not thats why I am asking my enumerator
Code:
enum times
{
time_1
time_2
time_3
time_4
time_5
time_6
time_7
time_8
time_9
}
Is there some way I could enumerate through each value of the enumerator :S if that makes any since at all.
eg.
Code:
foreach evalue in times
{
if (evalue == time_6) dosomething();
}
-
May 5th, 2004, 02:33 PM
#2
like this maybe
VB Code:
[color=blue]enum[/color] times
{
time_1,
time_2,
time_3,
time_4,
time_5,
time_6,
time_7,
time_8,
time_9,
}
[color=green]// to implement in a void or something ...[/color]
times tm = new times();
[color=blue]foreach[/color](System.Reflection.FieldInfo f [color=blue]in[/color] tm.GetType().GetFields())
{
[color=blue]if[/color](f.Name != "time_6")
{
[color=green]// do something. [/color]
}
}
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
May 5th, 2004, 05:26 PM
#3
Thread Starter
Addicted Member
good but I really need to return the values not the names
-
May 6th, 2004, 02:57 PM
#4
for the values m8 you do this ...
VB Code:
[color=blue]private void[/color] button1_Click([color=blue]object[/color] sender, System.EventArgs e)
{
times tm = new times();
[color=blue]foreach[/color](System.Reflection.FieldInfo f [color=blue]in[/color] tm.GetType().GetFields())
{
[color=blue]if[/color](Convert.ToInt32(f.GetValue(tm)) == 6)
{
MessageBox.Show("item value 6 found");
}
}
}
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
May 7th, 2004, 09:42 AM
#5
Thread Starter
Addicted Member
o tanx, I ended up not using but it's nice ot know ;p
-
May 10th, 2004, 07:58 AM
#6
Re: Can you For Each an Enumerator?
Originally posted by Tewl
Is there some way I could enumerate through each value of the enumerator :S if that makes any since at all.
That's what arrays are for
I don't live here any more.
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
|