如何将整数值添加到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 同学见面花束祝福语简短
14 五一假期祝福语幽默简短
15 离职欢送敬酒祝福语简短
16 对学弟的祝福语简短
17 考老师辞职祝福语简短
18 祝福语驱散霉运的话简短