2016-09-14 69 views

回答

2
var secondLine = example.Split('\n')[1]; 
2

使用字符串分割功能:

string[] split = example.Split('\n'); 

各自爲陣的項目將是一條直線。然後你可以通過索引訪問你想要的那個。

0

可以使用此代碼:

串[]文本= example.split( 「\ n」);

text [1]將成爲第二行內容。

0

試試這個。通過使用\r\n\n

string example = "Useless info\nI want this line in it's own string or part of a string[]\nUseless info"; 
    string[] lines = example.Split(new string[] 
    { 
    "\r\n", "\n" 
    } 

    , StringSplitOptions.None); 

    foreach (var line in lines) 
    { 
     Console.WriteLine(line); 
    } 
拆分爲換行