最终的线在VB.NET标识? [英] End-of-line identifier in VB.NET?
本文介绍了最终的线在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 toChr(13) & Chr(10)
).- Controls exists in the
Microsoft.VisualBasic
namespace, effectively making it a legacy/backwards-compatibility option, likevbCrLf
. Always stay clear of legacy code if possible.
这篇关于最终的线在VB.NET标识?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文