官术网_书友最值得收藏!

Converting an array to a list of integers

Next, enter the following below this line:

List<int> lst = new int[] { 1, 2, 12, 4, 5, -10, 5, 25, 54 }.ToList();

To make a list of integers, we say lst = new int[]. Then we specify the initializer list and the values shown here. It doesn't matter what values you use. I'll show you some of the methods. Of course, as you can imagine, there are many of them.

Now, note that you could not stop writing this line after the array. If you did, the pop-up tip would say Cannot implicitly convert type 'int[]' System.Collections.Generic.List<int>'; so you have to add .ToList(). You can convert an array to a list of integers.

主站蜘蛛池模板: 康平县| 屏东县| 麦盖提县| 东宁县| 平遥县| 大竹县| 登封市| 天门市| 正镶白旗| 西城区| 福清市| 吴川市| 东辽县| 东丽区| 嘉荫县| 雷波县| 电白县| 拉萨市| 肃北| 德惠市| 黄冈市| 杂多县| 新和县| 当雄县| 翁源县| 门源| 陵水| 阿克苏市| 西和县| 永善县| 阿瓦提县| 洞口县| 满洲里市| 克拉玛依市| 慈溪市| 久治县| 盐津县| 漳平市| 邯郸县| 宜章县| 吴旗县|