New line in string, \n not working

A

Assimalyst

Hi,

I have the following string written in c#:

string strAddressAll = strAddress1 + ",\n" + strAddress2 + ",\n" +
strAddress3 + ",\n" + strCountry + ",\n" + strPostcode;

But it all appears on one line?

I've also tried adding in :

+ System.Environment.NewLine

but that didn't work either??

Any ideas what's going on?

Thanks
 
V

Vadym Stetsyak

Where do you display the text? Maybe control is not multiline or smth like
this.
Or complete CRLF combination will do?

FYI CRLF ( carriage return line feed ) - \r\n :)
 
G

Guest

What are you using to display the string strAddressAll?

If you are using a TextBox, be sure that you have set it’s MultiLine
property to true.

Brendan
 
A

Assimalyst

I'm using it to set a Label.Text, it dosen't seem to have a multiline
option.

Thanks
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Nop, a Label does not have it, depending of the sizse of the label it does
include the new line.

You could either use more than one label (not good) or try to justify the
text with whitespaces (better idea)

cheers,
 

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

Top