如何在 C# 中宣告一個空字串陣列?
在 C# 中,你可以把字串用作一組字元,不過,通常的做法是使用 string 關鍵字來宣告字串變數。string 關鍵字是 System.String 類的別名。
宣告一個空字串。
string[] arr = new string[] {}; // empty string
現在讓我們看看列印這個空字串會發生什麼。
示例
using System; namespace Demo { class Program { static void Main(string[] args) { string[] arr = new string[] {}; // empty string string res = String.Join(" ", arr); // let us now print the empty string Console.WriteLine("This won't print any message since its an empty string {0}", res); } } }
輸出
This won't print any message since its an empty string
廣告