Hi Vincenzo67,
Switch works for one condition. How it can work for multiple?
Your string has 2 and also 4. Thus such cases switch will not work.
Switch will work only for either 2 or either 4.
In your case switch statement returns multiple character of List of string you have created.
You need to split your string and run loop through it and then you can check for different cases.
Refer below code.
string sp_concat = "2, 4";
foreach (string item in sp_concat.Split(','))
{
switch (item.Trim())
{
case "1":
Console.WriteLine("Has 1");
break;
case "2":
Console.WriteLine("Has 2");
break;
case "3":
Console.WriteLine("Has 3");
break;
case "4":
Console.WriteLine("Has 4");
break;
default:
break;
}
}