Hi,
I'm not an expert at nested for loops and I need help with the following...
I need to extract numeric values from a string and 'discard' any alphabetical characters in the same string. In this case, there will always only be a sequence of 2 numeric strings.
The purpose of this is to append station using racks, should the station need expanding at a later stage. Here's what I have...
What I need help with is setting the 'rowNumber' and 'columnNumber' variables with the values i and j return, respectively. I want i to be 'rowNumber' and j to be 'columnNumer'.
Lets say, for instance, stationCoordina tes' value is "Row33Col44 ", I want the 33 (i) and 44 (j), which value's should be incremented accordingly in my append method. Any ideas?
I'm not an expert at nested for loops and I need help with the following...
I need to extract numeric values from a string and 'discard' any alphabetical characters in the same string. In this case, there will always only be a sequence of 2 numeric strings.
The purpose of this is to append station using racks, should the station need expanding at a later stage. Here's what I have...
Code:
string stationCoordinates = stationObjects.StationXY;
char[] digits = new char[] { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' };
int rowNumber = 0;
int columnNumber = 0;
StringBuilder numericString = new StringBuilder();
for (int i = 0; i < stationCoordinates.Length; i++)
{
for (int j = 0; j < stationCoordinates.Length; j++)
{
if (char.IsNumber(stationCoordinates[i]))
{
numericString.Append(stationCoordinates[i]);
rowNumber = i;
}
}
}
Lets say, for instance, stationCoordina tes' value is "Row33Col44 ", I want the 33 (i) and 44 (j), which value's should be incremented accordingly in my append method. Any ideas?
Comment