- Beginning C# 7 Hands-On:Advanced Language Features
- Tom Owsiak
- 122字
- 2021-07-02 15:29:28
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.
推薦閱讀
- Learn ECMAScript(Second Edition)
- 深度實踐OpenStack:基于Python的OpenStack組件開發
- Python for Secret Agents:Volume II
- 看透JavaScript:原理、方法與實踐
- ASP.NET動態網頁設計教程(第三版)
- Java Web基礎與實例教程
- Magento 1.8 Development Cookbook
- Visual C++應用開發
- SQL Server 2016數據庫應用與開發
- Unreal Engine 4 Shaders and Effects Cookbook
- Learning OpenStack Networking(Neutron)
- Getting Started with Gulp
- Java EE企業級應用開發教程(Spring+Spring MVC+MyBatis)
- Spring MVC+MyBatis開發從入門到項目實踐(超值版)
- QlikView Unlocked