Is it possible to pass over a string, finding the white spaces?
For example a data set of:
string myString = "aa bbb cccc dd";
How could I loop through and detect each white space, and manipulate that space?
I need to do this in the most effecient way possible.
Thanks.
UPDATE:
I need to manipulate the space by increasing the white space from an integer value. So for instance increase the space to have 3 white spaces instead of one. I’d like to make it go through each white space in one loop, any method of doing this already in .NET? By white space I mean a ‘ ‘.
If you want to replace all whitespace in one swoop, you can do:
If you want to go case by case (that is, not just a mass replace), you can loop through
IndexOf():UPDATE
As per your update, you could replace single spaces with the number of spaces specified by a variable (such as numSpaces) as follows: