Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Environment.NewLine equivalent for compact framework 2.0

What is the best practice for inserting a newline character into a string in the .NET Compact Framework 2.0 SP2?

like image 477
Joel B Avatar asked Mar 12 '26 14:03

Joel B


1 Answers

Does the Compact Framework not support Environment.NewLine? Ah well. You can just use "\r\n" - if you know you're on the compact framework, it's not like you're running on Mono where the default new line may be different :)

You could always create your own string property:

public static class PortableEnvironment
{
    public static string NewLine
    {
        get
        {
#if COMPACT_FRAMEWORK
            return "\r\n";
#else
            return Environment.NewLine;
#endif
        }
    }
}
like image 141
Jon Skeet Avatar answered Mar 14 '26 04:03

Jon Skeet