-4

Is it possible to look up if a string in contained in an Array, with a switch case?

 string text = "blalbac";
 string arr[] = {"a","b","c"};

  switch (text)
  {
    case arr.Contains(filename):
      //do..
      break;
  }
Ian
  • 35
  • 1
  • 6

1 Answers1

1

I’m not sure what you’re trying to do. Do you want something like

foreach(string item in arr)
{
    if(text.Contains(item))
    {
        ...
    }
}
nl-x
  • 11,762
  • 7
  • 33
  • 61