i am getting "a constant value is required" error when i use the enum value
in case statement/
Any ideas?
sample code:
myconfig.cs
--
public enum WebHostingTypes
{
[Description("BASIC")] Basic,
[Description("PLUS")] Plus,
[Description("PREM")] Premium
}
product.cs
--
switch(WebHostingType)
{
case objCommon.GetEnumValueDescription(myconfig.WebHostingTypes.Basic):
break;
case ....
}
Even if i tried using a something like
public enum Volume
{
Low,
Medium,
High
}
string myVolume = "Medium";
switch(myVolume)
{
case myconfig.Volume.Medium:
break;
case ....
}
- GaneEnumerated values are numbers. If you treat them as such you will have no
problems with them.
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
What You S

"gane kol" <ganekol@.softca.com> wrote in message
news:OY%23kHOlUFHA.1404@.TK2MSFTNGP09.phx.gbl...
> Hi
> i am getting "a constant value is required" error when i use the enum
> value
> in case statement/
> Any ideas?
> sample code:
> myconfig.cs
> --
> public enum WebHostingTypes
> {
> [Description("BASIC")] Basic,
> [Description("PLUS")] Plus,
> [Description("PREM")] Premium
> }
> product.cs
> --
> switch(WebHostingType)
> {
> case objCommon.GetEnumValueDescription(myconfig.WebHostingTypes.Basic):
> break;
> case ....
> }
> --
> Even if i tried using a something like
> public enum Volume
> {
> Low,
> Medium,
> High
> }
> string myVolume = "Medium";
> switch(myVolume)
> {
> case myconfig.Volume.Medium:
> break;
> case ....
> }
> - Gane
>
well, ok. But i couldnt figure why the example below (2nd Example) is not
working for me, but worked for others (found in some tech articles).
"Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
news:eq2zl2lUFHA.3596@.TK2MSFTNGP14.phx.gbl...
> Enumerated values are numbers. If you treat them as such you will have no
> problems with them.
> --
> HTH,
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> What You S

> "gane kol" <ganekol@.softca.com> wrote in message
> news:OY%23kHOlUFHA.1404@.TK2MSFTNGP09.phx.gbl...
*********************** 2ND EXAMPLE
>
> well, ok. But i couldnt figure why the example below (2nd Example) is not
> working for me, but worked for others (found in some tech articles).
I wouldn't know, as I haven't seen them. However, I can't see any good
reason for doing so. You have to be careful what tech articles you read, and
by whom they are written.
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
What You S

"gane kol" <ganekol@.softca.com> wrote in message
news:umQZaHmUFHA.3280@.TK2MSFTNGP10.phx.gbl...
> well, ok. But i couldnt figure why the example below (2nd Example) is not
> working for me, but worked for others (found in some tech articles).
>
> "Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
> news:eq2zl2lUFHA.3596@.TK2MSFTNGP14.phx.gbl...
>
>
> *********************** 2ND EXAMPLE
>
>
0 comments:
Post a Comment