更新时间:2023-12-03 09:19:52
您不能向数组添加项,因为它具有固定长度.您正在寻找的是一个 List
,稍后可以使用 list.ToArray()
将其转换为数组,例如
You can't add items to an array, since it has fixed length. What you're looking for is a List<string>
, which can later be turned to an array using list.ToArray()
, e.g.
List<string> list = new List<string>();
list.Add("Hi");
String[] str = list.ToArray();