Reading text lines into an array c#?

C# discussion

Moderator: moderators

rank: <50 posts
rank: <50 posts
Posts: 24
Joined: Mon Nov 22, 2010 5:44 am
Reputation: 0
Gender: None specified

Reading text lines into an array c#?

Postby chanika » Thu Dec 02, 2010 3:27 am

I am writing an app that allows a user to navigate to a .txt file and with the file selected I need it to read the files lines creating a new array member based off each line. (though if you can think of an easier solution please feel free to mention it.)

I am reading the file and using the line count to set the number of array members:
// count the number of lines in a file
newobject.Count = newobject.CountLinesInFile(@newobject.cs?
// create an array with elements for all lines
string[] lines = new string[(newobject.Count)];

How can I tell it to read the line of text UNTIL "\n" or "\r" so that each new line is its own member in the array "lines."
khao san road

Please add to your ad blocker white list.
Thank you for your support.

Return to “C# coding for NeoTicker”