Getting just the number of a String C# -
i have string this:
string mainstring = "11;22;33;44;55;66";
and want numbers , put them in array or list.
what did far ;
positions:
static void main(string[] args) { string mainstring = "11;22;33;44;55;66"; int count = mainstring.split(';').length - 1; int firstcomma = mainstring.indexof(';'); int index = mainstring.indexof(';'); ; system.console.writeline(firstcomma); (int = 1; < count; i++) { index = mainstring.indexof(';', index + 1); system.console.writeline(index); } console.readkey(); }
you using string.split. convert strings ints.
string mainstring = "11;22;33;44;55;66"; int[] ints = mainstring.split(';').select(x => int.parse(x)).toarray();
Comments
Post a Comment