473,378 Members | 1,422 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

problem with string.Split delimeter

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



Nov 16 '05 #1
2 3621
On Mon, 20 Dec 2004 10:31:42 -0800, Ron wrote:
str2 = str1.Split((char)"\n"); //problem here


Use single quotes to define a char literal.

str2 = str1.Split('\n');
--
Tom Porterfield
Nov 16 '05 #2
Ron
Thanks very much. That worked perfectly!

-----Original Message-----
On Mon, 20 Dec 2004 10:31:42 -0800, Ron wrote:
str2 = str1.Split((char)"\n"); //problem here


Use single quotes to define a char literal.

str2 = str1.Split('\n');
--
Tom Porterfield
.

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Laphan | last post by:
Hi All Need another favour. I have an Access memo field that contains a list of single random words that are separated by a single space. What I need to do is extract a random word from this...
6
by: Ram Laxman | last post by:
Iam new bie to C++ programming.. I want to write a program which will read the Comma separated values(CSV) file column wise. For example: In a.txt: "TicketNumber","Phone","CarNumber"...
5
by: Jason | last post by:
Hi all basically its what i said in the subject. Would just like to know how to split a string using a STRING value as the delimeter and not a CHAR as the delimeter. Example: "I like Cheese",...
10
by: CodeRazor | last post by:
Is there a string method that allows gives you the number of times a substring appears in your string. Looping through my string performing IndexOf("substring",startPos), seems like overkill. ...
4
by: Mike Kanski | last post by:
Here's an expample: dim s as string s=""c:\blah blah\"" ""c:\koko\"" ""c:\booo boo\"" console.write ubound(s.split(""" """)) result of ubound is 3 Should be 2 ! What i'm trying to do is...
5
by: WoodenSword | last post by:
Hi, I am trying to read a huge text file (2GB) using StreamReader. I do this: Read a line (readline()) I process the line a bit (split it with delimeter and change fields a bit) execute...
4
by: romy | last post by:
I can't find the then class for dividing strings into tokens by a specific delimeter
1
by: svijay | last post by:
hi I have got a strange problem. May I know any solution for this. Here is the detailed description about the problem We have got a mainframe system and also production and development...
1
by: Sheena777 | last post by:
I am getting a string from a user and Would like to split the Data base on certain cinditions, I know how to split the sting with an Array and the Split method. I am fine if the user has put that...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.