valueArray is a multidimensional array of objects, according to your parameter definition. switch does not support that.
- You can’t and wouldn’t perform a switch on an array of values;
switchoperates on a single value. You can useforeachto flatten the array, iterate over each value, and apply the switch, however… - As the error indicates,
objectcannot be used inswitchstatements, only types those indicated in the error message. If each value is an integer, cast the value to an int in theswitch.
Update OK, now they are strings again.
Example:
foreach(var value in valueArray)
{
switch(value as string)
{
case "ITemplate.GetAllTemplate":
break;
case "ITask.GetTaskInstanceFromTemplate":
break;
case "CreateTask":
break;
case "UpdateDatabase":
break;
case "GetTaskStatus":
break;
case "VerifyValue":
break;
}
}
13
solved Issue using switch case statement [closed]