Monday, 15 July 2013

c# - Delimit string and put it in listbox -



c# - Delimit string and put it in listbox -

i have string like:

one,one,one,one,two,two,two,two,three,three,three,three,four,four,four,four,...

and i'd delimit after every 4th comma , store list box, this:

one,one,one,one, two,two,two,two, three,three,three,three, four,four,four,four, ...

what should appropriate way this? should supposed utilize regex somehow delimit string?

thanks

linqless alternative;

int s = 0, n = 0, len = inputstring.length; (var = 0; < len; i++) { if (inputstring[i] == ',' && ++n % 4 == 0 || == len - 1) { alistbox.items.add(inputstring.substring(s, - s + 1)); s = + 1; } }

c# regex string listbox

No comments:

Post a Comment