String Join() 方法
字串中的 Join () 方法連線字串陣列的所有元素,並在每個元素之間使用指定的分割符。
在以下示例中,我們有一個多行字串,並將分隔符設定為 “
” −
String.Join("
", starray);示例
以下為完整示例 −
using System;
namespace StringApplication {
class StringProg {
static void Main(string[] args) {
string[] starray = new string[]{"Down the way nights are dark",
"And the sun shines daily on the mountaintop",
"I took a trip on a sailing ship",
"And when I reached Jamaica",
"I made a stop"};
string str = String.Join("
", starray);
Console.WriteLine(str);
}
}
}輸出
Down the way nights are dark And the sun shines daily on the mountain top I took a trip on a sailing ship And when I reached Jamaica I made a stop
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP