如何将整数值添加到C#列表?
要将整数值添加到C#中的列表,请使用Add()方法。
首先,在C#中声明一个整数列表-
List<int> list1 = new List<int>();
现在添加整数值-
list1.Add(900); list1.Add(400); list1.Add(300);
让我们看完整的代码-
示例
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace Demo {
public class Program {
public static void Main(String[] args) {
List<int> list1 = new List<int>();
list1.Add(900);
list1.Add(400);
list1.Add(300);
Console.WriteLine(list1.Count);
}
}
}热门推荐
10 结婚祝福语亲姐姐简短
11 二胎祝福语简短霸气
12 哥哥病了祝福语大全简短
13 60岁长辈祝福语简短
14 朋友节最简短祝福语
15 高考毕业祝福语简短励志
16 剪简短的新年祝福语
17 小年好的祝福语简短
18 同事调动的祝福语简短