如何在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);
//现在让我们打印空字符串
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
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短