核心代码:
using system; using system.collections.generic; using system.io; using system.linq; using system.text; using system.threading.tasks; namespace consoleapplication10 { class program { static void main(string[] args) { list<int> list = new list<int>(); list.add(1);//插入单个元素 list.addrange(new int[] { 1, 2, 3, 4 });//插入一个集合 //集合转为数组 int[] nums = list.toarray(); foreach (var item in nums) { console.writeline(item); } console.writeline(); //数组转为集合 int[] nums2 = new int[] { 22,33,44}; list<int> newlist = nums2.tolist(); foreach (var item in newlist) { console.writeline(item); } console.readkey(); } } }
效果图:
如对本文有疑问, 点击进行留言回复!!
使用Visual Studio2019创建C#项目(窗体应用程序、控制台应用程序、Web应用程序)
C#实现获取本地内网(局域网)和外网(公网)IP地址的方法分析
网友评论