[Solved] Issue using switch case statement [closed]


valueArray is a multidimensional array of objects, according to your parameter definition. switch does not support that.

  1. You can’t and wouldn’t perform a switch on an array of values; switch operates on a single value. You can use foreach to flatten the array, iterate over each value, and apply the switch, however…
  2. As the error indicates, object cannot be used in switch statements, only types those indicated in the error message. If each value is an integer, cast the value to an int in the switch.

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]