K
kaede
Hi all,
Given the following textfile (i.e test.txt)
5 5
5 2 E
aeiou
4 3 Y
abcdefghij
What is the best way to read the file in and parse the data to its appropriate type?
I was using the following method, but it looks really tedious and not efficient
// Read File
string[] raw = new string[5];
StreamReader reader = File.OpenText("test.txt");
int i = 0;
while(reader.Peek() >= 0)
{
raw = reader.ReadLine();
++i;
}
// remove delimiter data
string[] data_arraySize = data[0].Split( new char [] { ' ' } );
string[] data_intintChar1 = data[1].Split( new char [] { ' ' } );
string[] data_charArray1 = data[2];
string[] data_intintChar2 = data[3].Split( new char [] { ' ' } );
string[] data_charArray2 = data[4];
// for each data type do conversion
int x = data_arraySize[0].ToInt()
int y = data_arraySize[0].ToInt()
Any help would be appreciated!!!
Given the following textfile (i.e test.txt)
5 5
5 2 E
aeiou
4 3 Y
abcdefghij
What is the best way to read the file in and parse the data to its appropriate type?
I was using the following method, but it looks really tedious and not efficient
// Read File
string[] raw = new string[5];
StreamReader reader = File.OpenText("test.txt");
int i = 0;
while(reader.Peek() >= 0)
{
raw = reader.ReadLine();
++i;
}
// remove delimiter data
string[] data_arraySize = data[0].Split( new char [] { ' ' } );
string[] data_intintChar1 = data[1].Split( new char [] { ' ' } );
string[] data_charArray1 = data[2];
string[] data_intintChar2 = data[3].Split( new char [] { ' ' } );
string[] data_charArray2 = data[4];
// for each data type do conversion
int x = data_arraySize[0].ToInt()
int y = data_arraySize[0].ToInt()
Any help would be appreciated!!!