本文介绍了在C#CRLF解析蓝调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码:

 字符串MYTEST =Line1Test+ Environment.NewLine + 
Line2Test + Environment.NewLine +
Line3Test+ Environment.NewLine;
的String [] = parseStr myTest.Split(Environment.NewLine.ToCharArray());



什么我得到的数据是新的阵列中的每个其他行。我想这是因为分割线分割为行和回车,但我怎么能只得到每行一个元素?


解决方案

 的String [] = parseStr myTest.Split(
新的String [] {} Environment.NewLine,
StringSplitOptions.None
);


I have the following code:

  string myTest = "Line1Test" + Environment.NewLine +
                  "Line2Test" + Environment.NewLine +
                  "Line3Test" + Environment.NewLine;
  string[] parseStr = myTest.Split(Environment.NewLine.ToCharArray());

What I'm getting is data every other line in the new array. I think this is because the split line is splitting for both line feeds and carriage returns, but how can I just get one element per line?

解决方案
string[] parseStr = myTest.Split(
    new string[] { Environment.NewLine },
    StringSplitOptions.None
);

这篇关于在C#CRLF解析蓝调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 15:36