如何在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 家长回复节日祝福语简短
18 给外婆敬酒祝福语简短