如何在 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