如何在 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
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP