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

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -