Click to See Complete Forum and Search --> : How reset the Existing enum type values


sathyboopathiraja
March 9th, 2009, 01:06 AM
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!.....

BigEd781
March 9th, 2009, 02:30 AM
You cannot change the integral values of enum elements at runtime. You should make another enum if you need different values.

Mutant_Fruit
March 9th, 2009, 03:58 AM
If you want an enum with all the values equal to each other, then the enum is useless.


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.

sathyboopathiraja
March 9th, 2009, 04:30 AM
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

BigEd781
March 9th, 2009, 11:55 AM
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.