easyer way?

W

WebBuilder451

the radio button list is bound to the enum, but to preselect a value i need
to to d all of this. There hase to be a less verbose way?

** paymentType is the Enum

rblPayType.SelectedValue = Enum.GetName(typeof(PaymentType),
PaymentType.Undefined);
--
(i''ll be asking a lot of these, but I find C# totally way cooler than vb
and there''s no go''n back!!!)
thanks (as always)

kes
 
P

Pavel Minaev

the radio button list is bound to the enum, but to preselect a value i need
to to d all of this. There hase to be a less verbose way?

** paymentType is the Enum

rblPayType.SelectedValue = Enum.GetName(typeof(PaymentType),
PaymentType.Undefined);

PaymentType.Undefined.ToString() will do the same.
Will this work???
rblPayType.SelectedValue = (string)PaymentType.Undefined;

No, it will not.
 
D

David

the radio button list is bound to the enum, but to preselect a value i
need
to to d all of this. There hase to be a less verbose way?

** paymentType is the Enum

rblPayType.SelectedValue = Enum.GetName(typeof(PaymentType),
PaymentType.Undefined);

PaymentType.Undefined.ToString() will do the same.
Will this work???
rblPayType.SelectedValue = (string)PaymentType.Undefined;

No, it will not.


Hi Pavel,

I never tried it like I suggested. I have always used the enum as an int, by
using it as (int)MyEnum.MyEnumValue.

If I wanted a string out, my next logical would have been to try
(string)MyEnum.MyEnumValue (because the int cast works) and if that didn't
work, do the ToString() method.

Even though I have been writing C# for 5 years and vbscript for another 7,
there are still things I have not done or tried. I would just experiment to
see what worked.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 
Y

YankeeImperialistDog

i know tried that. I don't really mind the verbosity that much, but for the
sake of "Art" ;) it'd be cool
 
Y

YankeeImperialistDog

the cast is the "native way" to get the value. I may try to extend enum some
day for the fun of it. Maybe overload the tostring method or something.
 
Y

YankeeImperialistDog

i'm too much, real bad day or something PaymentType.Undefined.ToString();
WORKS!!!!!!!

ok, i'll take this on on the chin and deserve it!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top