|
-
March 9th, 2009, 01:06 AM
#1
How reset the Existing enum type values
Dear All,
I am using enum type in my code, i need to reset the existing enum type. how can i achieve this.
public enum shape { line = 1, Rectangle, Circle };
here,
line=1,
Rectangle=2,
Circle=3
I need to reset this as ,
line=0,
Rectangle=0,
Circle=0
How can i reset this enum type. If Any one known about this kindly guide me.
With reggards,
Boopathiraja.N.
Thanks in Advance for your guidance!.....
-
March 9th, 2009, 02:30 AM
#2
Re: How reset the Existing enum type values
You cannot change the integral values of enum elements at runtime. You should make another enum if you need different values.
-
March 9th, 2009, 03:58 AM
#3
Re: How reset the Existing enum type values
If you want an enum with all the values equal to each other, then the enum is useless.
Code:
enum Shapes {
Line = 0,
Circle = 0
}
public void Method ()
{
Shapes shape = Shapes.Line;
if (shape == Shapes.Circle)
throw new WtfException ();
}
That code will throw a WtfException. Is this what you really want? If so, then you don't want an enum.
www.monotorrent.com For all your .NET bittorrent needs
NOTE: My code snippets are just snippets. They demonstrate an idea which can be adapted by you to solve your problem. They are not 100% complete and fully functional solutions equipped with error handling.
-
March 9th, 2009, 04:30 AM
#4
Re: How reset the Existing enum type values
Dear Mutant_Fruit & BigEd781,
Thanks for ur guidance. This information proof for me. if i say in mine way to others they won't accept. that's why i asked guidance from your like senior.
once again thansks for ur guidance.
With Regards,
Boopathiraja.N
-
March 9th, 2009, 11:55 AM
#5
Re: How reset the Existing enum type values
Mutant, I can't give you rep, but +1 for making me laugh with the WtfException class. Hopefully the OP can convince their co-workers that they do not understand what an enum is for.
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
|