It was a bit of hyperbole. Any time you are parsing string data you want to understand what possible user inputs could cause you problems and make sure your string is scrubbed before you split it. If there is a possibility of newline characters, carriage returns, or inconsistent tabs you want to address those. The simple solution is a string replace, there are more advanced strategies using regular expressions and such. But in favor of simplicity try something like this:
class Program
{
static void Main(string[] args)
{
string CurrentLine; // Remove this, it isn't necessary
string FilePath = "C:\\12837.SDF.txt"; // Change this to filePath, it is the generally correct way of naming method level variables
using (StreamReader sr = new StreamReader(FilePath)) // change to filePath also
{
while(!sr.EndOfStream)
{
string currentLine = sr.ReadLine();
GetSplit(currentLine.Replace("\t","").Replace("\r","").Replace("\n","");
// Console.WriteLine(array.Length.ToString());
}
}
}
private static void GetSplit(string CurrentLine)
{
string\[\] array = CurrentLine.Split(';');
string first = array\[0\];
string second = array\[1\];
string third = array\[2\];
string four = array\[3\];
// string five = array\[4\];
// string six = array\[5\];
// string seven = array\[6\];
// string eight = array\[7\];
Console.WriteLine(first + " " + second + " " + third + " " + four);
}
}
}
That is just a general idea on how to handle it. One thing you always want to be wary of is bad input, and the best way to deal with it is to aggressively control your strings by stripping out troublesome characters.