|
-
Jan 29th, 2003, 10:35 AM
#1
Thread Starter
Member
Equivalent vbCrLF in C#
is there an equivelent in C#
I want to write to a textbox and add empty lines in between words.
In VB I could just do:
txtTextBox = "Name " & vbCrLF
in C#, i'm currently doing:
txtTextBox = "Name " + (char)13 + (char)10;
there must be something in C#
-
Jan 29th, 2003, 12:07 PM
#2
Lively Member
-
Jan 29th, 2003, 07:18 PM
#3
also Environment.NewLineString or something to that effect.
Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.
-
Jan 30th, 2003, 09:01 AM
#4
But XfoxX's approach is the standard one:
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 30th, 2003, 10:25 AM
#5
Thread Starter
Member
Thanks.
"\r\n" worked fine.
-
Jan 30th, 2003, 11:11 AM
#6
It may be the standard approach, but if you're a "OMG Multiplatform .NET!!!!" Nazi, you'd use the Envirionment.NewLine variable.
....
Yeah, I use \r\n too.
Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.
-
Jan 30th, 2003, 01:15 PM
#7
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Feb 20th, 2003, 12:18 PM
#8
Junior Member
ok. then I have a follow up question.
If I have a big long string that I read from a file, and I want to split it into an array of lines, I use the following:
[code]
System.IO.StreamReader reader = System.IO.File.OpenText("c:\\directory\\filename.txt");
string wholeText = reader.ReadToEnd();
string[] textArray = wholeText.Split('\n');
[code]
This leaves me with an array of strings, but each one has a '\r' at the end. If I try to split on Environment.NewLineString then it yells at me for supplying a string instead of a char[]. So I use Environment.NewLineString.ToCharArray(). Since it finds both delimiters right next to each other, it gives an emptry string between each line in the array. What would be the proper way to split on the whole carriage return\line feed instead of just part of it?
-
Feb 20th, 2003, 06:52 PM
#9
Split at \n and trim away the \r.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Feb 21st, 2003, 09:04 AM
#10
Junior Member
That's what I'm doing now, I just don't really like it. It seems like there should be a cleaner way.
-
Feb 21st, 2003, 01:07 PM
#11
Sure there is: write your own split function.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Feb 21st, 2003, 03:25 PM
#12
Junior Member
Ah-ha! Something (marginally) cleaner than trimming off the '\r' at the end of each element of the array. Before I do the split, I do this:
wholeText = wholeText.Replace("\r", "");
Then the split does it all neat and tidy like I want.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|