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

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.

主站蜘蛛池模板: 宁安市| 钟山县| 张家港市| 安宁市| 安溪县| 乐亭县| 芜湖市| 读书| 浮梁县| 普安县| 隆子县| 海门市| 达拉特旗| 来凤县| 洪江市| 惠东县| 体育| 甘泉县| 健康| 大连市| 阳曲县| 满洲里市| 呼和浩特市| 湟中县| 镇安县| 两当县| 甘泉县| 禹城市| 上饶县| 高唐县| 榆社县| 乳山市| 安康市| 竹北市| 洛宁县| 芜湖市| 双流县| 南乐县| 梨树县| 荔波县| 仲巴县|