Lets say I have the following string:
string str = "aaa123aaa";
And I convert the given string to char array:
char[] array1 = str.ToArray();
Then I want to use foreach to loop through the elements to change all numbers to whitespace
foreach (char i in array1)
{
if (char.IsNumber(i)) { // ? }
}
How exactly do I change the character matching the criteria to whitespace? I've tried the following to no avail:
i = ' '; char(i) = ' '; array1(i) = ' ';
None of them work.
How exactly do I interact with the elements in foreach loop? It's simple if I use array, in that case I would simply use:
array1[i] = ' ';
But I've no idea how to do the same in foreach loop.
Thank you in advance!