Enum Question

  • Thread starter Thread starter George Durzi
  • Start date Start date
G

George Durzi

I have an enum defined as
public enum WineType
{
Bubbly,
Dessert,
Pink,
Red,
White
};

In the codebehind of a webform, I'm doing this:

switch ((WineType) drBottle["Type"])
{
// do something ...

drBottle["Type"] would come in as "Bubbly" or "Dessert", etc...

This compiles but I get an invalid Cast exception when the webform loads.

How do I cast this properly?
 
Use the Enum.Parse method

Tu-Thac
www.ongtech.co

----- George Durzi wrote: ----

I have an enum defined a
public enum WineTyp

Bubbly
Dessert
Pink
Red
Whit
}

In the codebehind of a webform, I'm doing this

switch ((WineType) drBottle["Type"]

// do something ..

drBottle["Type"] would come in as "Bubbly" or "Dessert", etc..

This compiles but I get an invalid Cast exception when the webform loads

How do I cast this properly
 
Back
Top