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!.....
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.
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.
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
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.