public static LineHolder ToLineHolder(this string str) { char[] chunk = new char[6]; byte count = 0; byte index = 0; for (int i = 0; i < str.Length; i++) { char k = str[i]; if (i == 0 && k != 77) { return(null); } if (Char.IsDigit(k) || k == 46) { // Build up a chunk of characters to process. chunk[index] = k; // We need this index to keep track of the length of characters in the char array as we can't rely on it's length. index++; } else { if (k == delim) { // if character is a delimeter, process the chunk and move to the next one. switch (count) { case 1: airportId = chunk.CharsToInt(index); break; case 2: planeNumber = chunk.CharsToInt(index); break; case 3: planeId = chunk.CharsToInt(index);; break; case 4: flightMiles = chunk.CharsToInt(index); break; case 5: //fuelCost = Decimal.Parse(new string(chunk)); fuelCost = chunk.CharsToDecimal(index); break; } // Clear the chunk and process the next one chunk = chunk.ClearAll(); count++; index = 0; } } if (count == maxColumns) { break; } } PROCESSED++; return(new LineHolder(airportId, planeNumber, planeId, flightMiles, fuelCost)); }