Search code examples
c#compact-framework

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?


Solution

  • 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
            }
        }
    }