Friday, May 8, 2009

sTreamReader in C# programming

StreamReader is designed for character input in a particular encoding, whereas the Stream class is designed for byte input and output. Use StreamReader for reading lines of information from a standard text file.

this is an example of stream reader in c# programming :
using System;
using System.Collections.Generic;
using System.IO;

class Program
{
static void Main()
{
//
// Read in a file line-by-line, and store it all in a List.
//

List list = new List();
using (StreamReader reader = new StreamReader("file.txt"))
{
string line;
while ((line = reader.ReadLine()) != null)
{
list.Add(line); // Add to list.
Console.WriteLine(line); // Write to console.
}
}
}
}


for more detail about it....you can see in this link is http://dotnetperls.com/Content/Using-Keyword-StreamReader.aspx


^_^

No comments:

Post a Comment