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.
Just split it:
var parts = gen.Split(';');
(Then you can iterate over that via foreach.)
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)
Console.WriteLine(substring);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With