[英]How insert element in last list?
I have a list m
. 我有一个清单
m
。 I want to insert an element to the end of this List
. 我想在此
List
的末尾插入一个元素。 Please tell me how I can do this. 请告诉我如何做到这一点。
public List<double> m = new List<double>();
m[0].Add(1);
m[1].Add(2);
m[2].Add(3);
I want the following output if I add element 7 to the end: 如果我将元素7添加到结尾,我想要以下输出:
1 2 3 7
m.Add(7);
will add it to the end of the list. 将它添加到列表的末尾。
What you are doing is trying to call the method Add on a double 你正在做的是尝试调用方法Add on a double
Use: 采用:
List<double> m = new List<double>();
m.Add(1);
m.Add(2);
m.Add(3);
m.Add(7);
You can use List<T>.Add()
method. 您可以使用
List<T>.Add()
方法。 Like; 喜欢;
Adds an object to the end of the List.
将对象添加到List的末尾 。
List<double> m = new List<double>();
m.Add(1);
m.Add(2);
m.Add(3);
m.Add(7);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.