G
genc_ ymeri at hotmail dot com
well, I making up a "scenario" which may not be the best but I can make my
point at least techincally..,.
I have this enum :
public enum JustTest
{
Volvo = 0x32324234,
Acura = 0x32423443,
Benz = 0x23423434
}
.....and from somewhere (WebService, DB, http or whatever) I get a string
"brandName"of a car name which may have any value e.g "Toyota", "Mazda",
"Benz" or "Volvo". All I want to know how can I check if the that name
exists in my enum list, and if it does I want to get its value as below
public int checkTheList (string brandName)
{
if JustTest.Exist (brandName)
return JustTest.ValueOf(brandName);
else
return -1;
}
Thank You in advance,
G.Y
PS:
Of course I can go and do an if statement for each of them like
if (brandName == JustTest.Volvo.Tostring()
.................................................................
but I think that's not too fency though.... it should be something else to
do it.
point at least techincally..,.
I have this enum :
public enum JustTest
{
Volvo = 0x32324234,
Acura = 0x32423443,
Benz = 0x23423434
}
.....and from somewhere (WebService, DB, http or whatever) I get a string
"brandName"of a car name which may have any value e.g "Toyota", "Mazda",
"Benz" or "Volvo". All I want to know how can I check if the that name
exists in my enum list, and if it does I want to get its value as below
public int checkTheList (string brandName)
{
if JustTest.Exist (brandName)
return JustTest.ValueOf(brandName);
else
return -1;
}
Thank You in advance,
G.Y
PS:
Of course I can go and do an if statement for each of them like
if (brandName == JustTest.Volvo.Tostring()
.................................................................
but I think that's not too fency though.... it should be something else to
do it.