Hi,
I have a Text file with two column X,Y (both are integer)
How Can I fill an array with these elements of text file in C# visual environment( not in console).
Thanks alot
Hi,
I have a Text file with two column X,Y (both are integer)
How Can I fill an array with these elements of text file in C# visual environment( not in console).
Thanks alot
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
AlanPosted Aug 29, 2008, 3:45 PM
Something like this:
string[] lines = System.IO.File.ReadAllLines("myfile.txt");
int[,] data = new int[lines.Length, 2];
string[] temp = null;
for(int i = 0; i < lines.Length; i++)
{
temp = lines[i].Split(',');
data[i,0] = int.Parse(temp[0]);
data[i,1] = int.Parse(temp[1]);
}