CRLF在C#中解析蓝调
我有以下代码:
string myTest = "Line1Test" + Environment.NewLine + "Line2Test" + Environment.NewLine + "Line3Test" + Environment.NewLine; string[] parseStr = myTest.Split(Environment.NewLine.ToCharArray());
我得到的是新数组中每隔一行的数据。 我认为这是因为分割线分为换行和回车,但我怎样才能每行得到一个元素?
string[] parseStr = myTest.Split( new string[] { Environment.NewLine }, StringSplitOptions.None );
您可能希望指定StringSplitOptions.RemoveEmptyEntries
,以及删除空条目。
string[] parseStr = myTest.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
另一种方式可能不是最好的
上述就是C#学习教程:CRLF在C#中解析蓝调分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!
string myTest = "Line1Test" + Environment.NewLine + "Line2Test" + Environment.NewLine + "Line3Test" + Environment.NewLine; string[] parseStr = myTest.Split(Environment.NewLine.ToCharArray()).Where(i => i != string.Empty).ToArray();
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/cdevelopment/958726.html