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

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.

主站蜘蛛池模板: 宁陕县| 察隅县| 油尖旺区| 宿松县| 罗源县| 宁阳县| 永清县| 临高县| 昌邑市| 邯郸县| 安岳县| 巩义市| 敖汉旗| 仁寿县| 淮南市| 平利县| 资溪县| 临沂市| 津南区| 保康县| 峨山| 全南县| 石城县| 宁陕县| 垣曲县| 永修县| 来宾市| 临颍县| 新丰县| 临沧市| 武清区| 大港区| 永城市| 乐清市| 台前县| 龙州县| 赣榆县| 长海县| 北宁市| 灵台县| 息烽县|