Newline in C# – \r\n ?

Coming originally from a VB background I was perfectly content using vbCrLf to add newlines to my strings.  Unable to find a C# equivalent, all my early C# code was scattered with ‘\r\n’ as a suitable replacement.
 
Works well, doesn’t it?
 
Well yes, right up until the point that you run it on a non-Windows system.  Unix, for example, uses just ‘\n’ and as you can imagine this makes things look just a little bit untidy.
 
Microsoft have very helpfully provided the perfect solution:
 
Environment.NewLine
 
This handy little fella returns the newline string for the current platform.
 
For those of you who are interested the full rundown is here… Environment.NewLine
Advertisements
This entry was posted in Programming. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s