Aug 09 2006

Environment NewLine Warning

Published by at 9:53 am under .NET

This is an old article and the information contained within it may be out of date, not reflect my current views and/or contain broken links. If you feel this article is still valid and requires updating, you can use the contact form to let me know. However, I make no guarantee that it will get updated.

I just found a site (via dotnetkicks.com) that is advocating the use of Environment.NewLine.

I would agree that it is good to go with the use of Environment.NewLine as it adds an extra layer of platform independance, i.e. you don’t need to worry about whether to use \r\n or just \n, and you don’t need to worry so much about what happens when you port the code from one .Net language to another. It isn’t however the answer to all problems.

Environment.NewLine only answers the problem of new line on the machine that it is running on. Where you may still run into problem is when you create a file using Environment.NewLine and then move the file to another platform. This is an age old problem and I don’t have a solution for it, just that you should be under no illusion that Environment.NewLine will solve this problem.

No responses yet