mykds mykds - 8 months ago 31
C# Question

Read string word by word with .Substring?

I'v got the following String

string gen = "Action;Adventure;Drama;Horror;

I tried to seperate the string word by word with .substring like:
gen.Substring(gen.IndexOf(';')+1, gen.IndexOf(';'))

But my output is just "Advent".

Any help?

Background: The string collects the names of checkboxes that are checked. The string is then saved in a database.
I want to read out the string an check each checkbox on another form.


Split it like this:

public class Example
   public static void Main()
      String value = "Action;Adventure;Drama;Horror";
      Char delimiter = ';';
      String[] substrings = value.Split(delimiter);
      foreach (var substring in substrings)