problem with string.Split delimeter

R

Ron

I am trying to read a delimited textfile to the console
window as follows:

using System.IO;

StreamReader oRead;
string str1;
object[] str2;

oRead = new StreamReader(strPath + @"\testFile.txt");
str1 = oRead.ReadToEnd();
oRead.Close();
str2 = str1.Split((char)"\n"); //problem here
foreach(object v in str2)
{
Console.WriteLine(v.ToString());
}

The delimiter is a carriage return char. Basically, I am
trying to migrate a vb.net app to c#. Could someone point
out how to do this correctly?

Thanks,
Ron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Problem with MemoryStream 2

Top