List<string> a = new List<string>();
a[0] = "100";
hostTextBox.Text = a[0];
List要用Add方法添加元素,只有元素存在了才能用[]索引访问或者修改
索引超出范围。必须为非负值并小于集合大小。
集合需使用add方法添加元素。
a[0] = "100"; ==> a.Add("100");
a[0] = "100"; ==> a.Add("100");
区别下array和list的不同,前者可以索引直接添加,因为Array需先创建指定个数的元素,而list动态系统负责维护元素数量,默认16个元素