473,396 Members | 1,734 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,396 software developers and data experts.

StringBuilder to Text

Hello, I a m building an email message in a StringBuilder Object and then
using the StringBuilder ToString() method to get it to regular text. It
appears to me that when I place a "\n" into the Stringbuilder object that
when this is translated into text, I loose the page break. Is this true and
I doing something wrong?

I'm guessing that I could insert a special character into the StringBuilder
object and then use the string Replace() method to translate that special
character into a "\n" and perhaps this would work.

Just wondering why it does not work when I place that value into the
StringBuilder Object.

Thanks
Jan 3 '06 #1
6 4190
How are you noticing that you loose the break? In what context is this
happening?

"Jim Heavey" <Ji*******@discussions.microsoft.com> wrote in message
news:1B**********************************@microsof t.com...
Hello, I a m building an email message in a StringBuilder Object and then
using the StringBuilder ToString() method to get it to regular text. It
appears to me that when I place a "\n" into the Stringbuilder object that
when this is translated into text, I loose the page break. Is this true
and
I doing something wrong?

I'm guessing that I could insert a special character into the
StringBuilder
object and then use the string Replace() method to translate that special
character into a "\n" and perhaps this would work.

Just wondering why it does not work when I place that value into the
StringBuilder Object.

Thanks

Jan 3 '06 #2
Have you considered using Environment.Newline instead of "\n"?

Example:

StringBuilder textBuilder = new StringBuilder(512);
textBuilder.Append("Dear John,");
textBuilder.Append(Environment.Newline)

Perhaps that will help.

carl

"Jim Heavey" <Ji*******@discussions.microsoft.com> wrote in message
news:1B**********************************@microsof t.com...
Hello, I a m building an email message in a StringBuilder Object and then
using the StringBuilder ToString() method to get it to regular text. It
appears to me that when I place a "\n" into the Stringbuilder object that
when this is translated into text, I loose the page break. Is this true
and
I doing something wrong?

I'm guessing that I could insert a special character into the
StringBuilder
object and then use the string Replace() method to translate that special
character into a "\n" and perhaps this would work.

Just wondering why it does not work when I place that value into the
StringBuilder Object.

Thanks

Jan 3 '06 #3
Try Environment.NewLine

Remy

Jan 3 '06 #4
I am loosing the page break when I use the StringBuilder ToString() method
when I am formatting an email message. I will try the Environment.NewLine()
method and see if that retains the line break.

Jan 3 '06 #5
Does the StringBuilder cause the newline disappear, or is it something with
the mail component. What happens if you just set the
StringBuilder.ToString() to a variable and looked at it, is the newline
gone?

"Jim Heavey" <Ji*******@discussions.microsoft.com> wrote in message
news:98**********************************@microsof t.com...
I am loosing the page break when I use the StringBuilder ToString() method
when I am formatting an email message. I will try the
Environment.NewLine()
method and see if that retains the line break.

Jan 3 '06 #6
I assume you are using c?

If you pass "\n" you'll get newline > chr(10)
If you want "\n" you might consider to use "\\n"
(Outlook express mangels this for me, use slash twice)


"Jim Heavey" <Ji*******@discussions.microsoft.com> schreef in bericht
news:1B**********************************@microsof t.com...
Hello, I a m building an email message in a StringBuilder Object and then
using the StringBuilder ToString() method to get it to regular text. It
appears to me that when I place a "\n" into the Stringbuilder object that
when this is translated into text, I loose the page break. Is this true
and
I doing something wrong?

I'm guessing that I could insert a special character into the
StringBuilder
object and then use the string Replace() method to translate that special
character into a "\n" and perhaps this would work.

Just wondering why it does not work when I place that value into the
StringBuilder Object.

Thanks

Jan 3 '06 #7

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

Similar topics

16
by: Alvin Bruney | last post by:
Is string builder intelligent enough to handle concats without behaving like string? Consider myStringBuilder.Append("one" + "two") what does the '+' do here? Because this syntax is also...
0
by: Bob | last post by:
I am using an API that needs a function pointer with the following prototype: void CALLBACK DXLExportStreamFunc ( const BYTE *bytes, DWORD length, void far *Context ) I get to pass it the...
0
by: Arne Adams | last post by:
Hi changing a StringBuilder through a deduced type throws an exception - Sample Code void editBuilder(System::Text::StringBuilder* t System::String* insertThis = S"inserted"...
0
by: I am Sam | last post by:
Ok I don't know what is the problem with my code But I am trying to build a newsletter that gathers parameters from 3 textbox controls and a Listbox control. The form then queries the event table...
4
by: Cor | last post by:
Hi Newsgroup, I have given an answer in this newsgroup about a "Replace". There came an answer on that I did not understand, so I have done some tests. I got the idea that someone said,...
7
by: Larry Bird | last post by:
I want to use the "replace" in the string builder class. I've imported the "system.text.stringbuilder" class into my project. However, I don't see the method call for...
33
by: genc_ymeri | last post by:
Hi over there, Propably this subject is discussed over and over several times. I did google it too but I was a little bit surprised what I read on internet when it comes 'when to use what'. Most...
12
by: Richard Lewis Haggard | last post by:
I thought that the whole point of StringBuilder was that it was supposed to be a faster way of building strings than string. However, I just put together a simple little application to do a...
7
by: rhkodiak | last post by:
I was in an interview question what is the most efficient way to sort a string for example "010101", the result would then be "000111", and write the code on how to do this. I wrote the code for...
34
by: raylopez99 | last post by:
StringBuilder better and faster than string for adding many strings. Look at the below. It's amazing how much faster StringBuilder is than string. The last loop below is telling: for adding...
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: 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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.