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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
AlanRank #669 · 3.6K reputationPosted Aug 29, 2008, 11:45 AM EDT
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]);
}