|
■No31439 (tamaboyo さん) に返信
> tamaboyoです。
>
> Environment.NewLineを使って単語をつなげた文字列を分解する際に、
> string.Split()を使って分解しようとしたところ、char[]とstringで型が違うとエラーが出ました。
問題ありませんょ?
using System;
class Program {
public static void Main() {
string nl = Environment.NewLine;
string input = "these" + nl + "words" + nl + "are" + nl +
"concatenated" + nl + "with" + nl + "(NewLine)";
string[] result = input.Split(new string[] { nl }, StringSplitOptions.None);
foreach ( string word in result ) {
Console.WriteLine("[{0}]", word);
}
}
}
|