C#控制台基础 一维string数组转成List集合

1 代码

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6
 7 namespace ConsoleApplication1
 8 {
 9     class Program
10     {
11         static void Main(string[] args)
12         {
13             string[] change = { "积善之家","必有余庆"};
14             List<string> contents = change.ToList();
15             foreach (var item in contents)
16             {
17                 Console.WriteLine(item);
18             }
19             Console.ReadKey();
20         }
21     }
22 }

2 效果

时间: 2024-08-10 06:27:29

C#控制台基础 一维string数组转成List集合的相关文章

JavaSE8基础 Arrays.toString 将一维int数组转成字符串输出

os :windows7 x64    jdk:jdk-8u131-windows-x64    ide:Eclipse Oxygen Release (4.7.0)        code: package jizuiku2; import java.util.Arrays; public class Demo100 { public static void main(String[] args) { String str = Arrays.toString(new int[] { 1, 2,

JavaScript基础 join() 将数组连接成字符串 化零为整

镇场诗: 清心感悟智慧语,不着世间名与利.学水处下纳百川,舍尽贡高我慢意. 学有小成返哺根,愿铸一良心博客.诚心于此写经验,愿见文者得启发.------------------------------------------ code: 1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=ut

将String数组转换成int数组

String[] arrResult = {"1","3"}; int[] sortArr=new int[arrResult.length];

页面提交 string数组和list对象集合举例

ajax表单提交 $.ajax({ cache: true, type: "POST", url:ajaxCallUrl, data:$('#yourformid').serialize(),// 你的formid async: false, error: function(request) { alert("Connection error"); }, success: function(data) { $("#commonLayout_appcresh

int数组与String数组互相转换和函数互相转换

今天在群里看到一人说起面试挂的一题,题目是Int数组转成String数组. 尽管是基础的问题.但却是基础中比較少用到的问题,因此大家工作都没怎么遇到,不会也非常正常.在此整理一下,先来个String与Int 互相转换吧 Int转String(举例两种) <span style="font-size:18px;">int num = 2; String st = "" + num;</span> <span style="fon

蓝鸥Unity开发基础—— 一维数组学习笔记

蓝鸥Unity开发基础-- 一维数组学习笔记 一.数组 之前我们学过很多数据类型,今天我们来学习数字,数字也是一种数据类型,那么,具体的数组是如何定义的? 数组:相同数据类型的成员组成的一组数据 Int类型数组:4  7  12  3  5--数组元素 Float数据类型数字:11.5 4.62 7.1 2.21 9.3--数组元素 数组中每一个元素都会分配一个数组下标,数组下标是从0开始的,有序排列,如:0 1 2 3 4 二.声明并初始化数组: 数组也是数据类型,所以也可以声明变量.使用ne

对N个数组进行操作。先把这N个一维数组合并成一个2为数组;然后进行操作

using System;using System.Collections.Generic;using System.Linq;using System.Collections;using System.Text;using System.Diagnostics; namespace Hecha.Test{ class Program { static void Main(string[] args) { List<string>[] aa = new List<string>[5

集合或数组转成String字符串

1.将集合转成String字符串 String s=""; for (int i = 0; i < numList.size(); i++) { if (s=="") { s=numList.get(i); }else { s=s+","+numList.get(i); } } 定义List集合,如: List<String> numList=new ArrayList<String>(); for(int i=1;

数组冒泡排序,文件读取,数据库读取,string类型的int数组转换成int数组

排序方式(枚举) 1 public enum SortBy 2 { 3 Asc, 4 Desc 5 } 数组冒泡排序方法 1 public class SortEntity 2 { 3 public static int[] SortArray(int[] array,SortBy sortby) 4 { 5 int flag; 6 switch (sortby) 7 { 8 case SortBy.Asc: 9 for (int i = 0; i < array.Length - 1; i++