[英]How to read in C# the Newline character in a SQLite database?
我正在处理的应用程序需要检索存储在SQLite
DB中的TEXT
字段中的Newline (\\n)
。 SQLite中\\n
的相应字符是什么? 因为
string[] words = str.Split(new string[] { @"\r\n" }, StringSplitOptions.None);
似乎不起作用。
string[] words = str.Split(new string[] { "\r\n" }, StringSplitOptions.None);
在""
之前没有@
,否则它意味着\\
和r
和\\
和n
......或者尝试
string[] words = str.Split(new string[] { "\n" }, StringSplitOptions.None);
取决于程序在db中保存的内容。
现在,如果你真的想要抓住任何东西,你可以......
string[] words = str.Split(new[] { "\r\n", "\r", "\n", StringSplitOptions.None);
@
表示
逐字字符串文字由@字符后跟双引号字符 ,零个或多个字符以及结束双引号字符组成。 一个简单的例子就是@“你好”。 在逐字字符串文字中,分隔符之间的字符是逐字解释的,唯一的例外是quote-escape-sequence。 特别是, 简单的转义序列和十六进制和Unicode转义序列不会在逐字字符串文字中处理 。 逐字字符串文字可以跨越多行。
您始终可以使用Environment.NewLine。
// Summary:
// Gets the newline string defined for this environment.
//
// Returns:
// A string containing "\r\n" for non-Unix platforms, or a string containing
// "\n" for Unix platforms.
public static string NewLine { get; }
string[] words = str.Split(new[] { Environment.NewLine} , StringSplitOptions.None);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.