I have the following type of code:
String strGroup = Request.QueryString["group"];
switch(strGroup.ToString){
case "Clients":
// do something here
break;
case "Addresses":
// do something here
break;
case "Matters":
// do something here
break;
case "Individuals":
// do something here
break;
case "Organisations":
// do something here
break;
default:
break;
}
But it's giving the following error:
A value of an integral type expected for switch(strGroup.ToString){
Change it to this:
switch(strGroup.ToString())
ToString() is a method, not a property. Therefore, you need to have the empty parenthesis.
Since strGroup is already a string, can't you just do the following and avoid a redundant call to .ToString()?
switch(strGroup)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With