C# 不固定大小的字符串数组:使用List<string>实现动态数据插入
在C#中,可以使用List
using System;
using System.Collections.Generic;
class Program
{
static void Main(string[] args)
{
List<string> myArray = new List<string>();
// 插入数据
myArray.Add("数据1");
myArray.Add("数据2");
myArray.Add("数据3");
// 输出数组元素
foreach (string data in myArray)
{
Console.WriteLine(data);
}
}
}
上述代码定义了一个名为myArray的List
原文地址: https://www.cveoy.top/t/topic/pd6U 著作权归作者所有。请勿转载和采集!