D
deko
I need to loop through a string and remove all characters except numbers or
letters. I am getting an ArgumentOutOfRangeException: "Index was out of
range. Must be non-negative and less than the size of the collection"
Not sure what is going on... any suggestions welcome!
public static string fixStr(string aStr)
{
StringBuilder bStr = new StringBuilder(aStr.Length);
for (int i = 0; i < aStr.Length; i++)
{
if (!Char.IsDigit(aStr) | !Char.IsLetter(aStr))
{
bStr.Remove(i,1);
}
}
return bStr.ToString();
}
letters. I am getting an ArgumentOutOfRangeException: "Index was out of
range. Must be non-negative and less than the size of the collection"
Not sure what is going on... any suggestions welcome!
public static string fixStr(string aStr)
{
StringBuilder bStr = new StringBuilder(aStr.Length);
for (int i = 0; i < aStr.Length; i++)
{
if (!Char.IsDigit(aStr) | !Char.IsLetter(aStr))
{
bStr.Remove(i,1);
}
}
return bStr.ToString();
}