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

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.

主站蜘蛛池模板: 济宁市| 子洲县| 黎城县| 巴中市| 昌都县| 钟山县| 南川市| 揭西县| 巴林右旗| 呼图壁县| 平顺县| 柘荣县| 长岭县| 祥云县| 南安市| 彭阳县| 建德市| 忻城县| 安多县| 藁城市| 庐江县| 喀喇| 上思县| 东乡| 新民市| 鲁山县| 华坪县| 大化| 大荔县| 大港区| 桦川县| 邹平县| 华安县| 偏关县| 娄烦县| 新疆| 汉寿县| 肇庆市| 龙泉市| 大宁县| 新兴县|