紧凑框架 2.0 的环境.NewLine 等效项

发布于 2024-10-08 07:59:09 字数 59 浏览 0 评论 0原文

在 .NET Compact Framework 2.0 SP2 中将换行符插入字符串的最佳实践是什么?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

飘过的浮云 2024-10-15 07:59:09

Compact Framework 不支持Environment.NewLine 吗?啊好吧。你可以只使用 "\r\n" - 如果你知道你在紧凑的框架上,它不像你在 Mono 上运行,默认的换行符可能会有所不同:)

您始终可以创建自己的字符串属性:

public static class PortableEnvironment
{
    public static string NewLine
    {
        get
        {
#if COMPACT_FRAMEWORK
            return "\r\n";
#else
            return Environment.NewLine;
#endif
        }
    }
}

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
        }
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文