最终的线在VB.NET标识? [英] End-of-line identifier in VB.NET?

查看:164
本文介绍了最终的线在VB.NET标识?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么

有很多选择:

  • vbCrLf
  • vbNewLine(vbCrLf显然别名)
  • ControlChars.CrLf
  • ControlChars.NewLine
  • Environment.NewLine
  • 在应用程序中的一些C#类的静态成员(需要混合语言解决方案):公共静态字符串LINEEND =\ r \ N的;
  • Global.Microsoft.VisualBasic.ChrW(13)及Global.Microsoft.VisualBasic.ChrW(10)(由Visual Studio设计,至少的 Visual Basic 2005中前preSS版,与物业文本框的的设置为True时,<大骨节病>移 + <大骨节病>返回用于在编辑属性的文本的。)
  • vbCrLf
  • vbNewLine (apparently an alias of vbCrLf)
  • ControlChars.CrLf
  • ControlChars.NewLine
  • Environment.NewLine
  • A static member in some C# class in the application (requires mixed-language solution): public static string LINEEND = "\r\n";
  • Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) (generated by the Visual Studio designer, at least Visual Basic 2005 Express Edition, for a TextBox with property Multiline set to True when Shift + Return is used while editing property Text.)

什么是最好的做法?

推荐答案

我相信它一般最有意义使用 Environment.NewLine 作为新行标识符,有许多原因:

I believe it generally makes most sense to use Environment.NewLine as the new-line identifier, for a number of reasons:

  • 这是一个环境依赖性只读变量。如果你碰巧运行你在Linux(例如)计划,则该值将仅仅是
  • vbCrLf 从VB6和早期的语言遗产不变。此外,它不是环境无关。
  • \ r \ñ已不是依赖于环境的,也不能在VB.NET很好地完成了同样的问题(你必须分配一个变量 CHR(13)及。CHR(10)
  • 控件存在于 Microsoft.VisualBasic程序命名空间,这实际上使得旧版/向后兼容的选项,如 vbCrLf 。始终保持清晰的遗留code如果可能的话。
  • It is an environment-dependent read-only variable. If you happen to be running your program on Linux (for example), then the value will simply be \n.
  • vbCrLf is a legacy constant from the VB6 and earlier languages. Also, it's not environment-independent.
  • \r\n has the same issue of not being environment-dependent, and also can't be done nicely in VB.NET (you'd have to assign a variable to Chr(13) & Chr(10)).
  • Controls exists in the Microsoft.VisualBasic namespace, effectively making it a legacy/backwards-compatibility option, like vbCrLf. Always stay clear of legacy code if possible.

这篇关于最终的线在VB.NET标识?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆