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