C# 程序创建空字符串数组
要创建空字符串数组 −
string[] str = new string[] {};
在上面,由于数组为空,我们并未向该数组添加元素。
即使我们循环数组,它也不会显示任何内容,如下所示 −
实例
using System; public class Demo { public static void Main() { string[] str = new string[] {}; Console.WriteLine("String Array elements won't get displayed since it's empty..."); for (int i = 0; i < str.Length; i++) { string res = str[i]; Console.WriteLine(res); } } }
输出
String Array elements won't get displayed since it's empty...
广告