1,从System.String[]转到List<System.String>

System.String[] str={"str","string","abc"};

List<System.String> listS=new List<System.String>(str);

2, 从List<System.String>转到System.String[]

List<System.String> listS=new List<System.String>();

listS.Add("str");

listS.Add("hello");

System.String[] str=listS.ToArray();

测试如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            System.String[] sA = { "str","string1","sting2","abc"};
            List<System.String> sL = new List<System.String>();
            for (System.Int32 i = 0; i < sA.Length;i++ )
            {
                Console.WriteLine("sA[{0}]={1}",i,sA[i]);
            }
            sL = new List<System.String>(sA);
            sL.Add("Hello!");
            foreach(System.String s in sL)
            {
                Console.WriteLine(s);
            }
            System.String[] nextString = sL.ToArray();
            Console.WriteLine("The Length of nextString is {0}",nextString.Length);
            Console.Read();
        }
    }
}

List<string>和string[]数组之间的相互转换,需要的朋友可以参考下的更多相关文章

  1. C#中List〈string〉和string[]数组之间的相互转换

    1,从System.String[]转到List<System.String> System.String[] str={"str","string" ...

  2. c# string 和 byte[]数组之间转换

    在文件流读取和存储过程当中,经常涉及到byte[]数组形式存储数据,再此过程中也涉及到String类型字符串和byte[]的类型转换,下面我们举例说明一下. 现在有一个字符串: string str ...

  3. c++中几种常见的类型转换。int与string的转换,float与string的转换以及string和long类型之间的相互转换。to_string函数的实现和应用。

    1.string转换为int a.采用标准库中atoi函数,对于float和龙类型也都有相应的标准库函数,比如浮点型atof(),long型atol(). 他的主要功能是将一个字符串转化为一个数字,在 ...

  4. list,set,map,数组之间的相互转换详细解析

    1.list转setSet set = new HashSet(new ArrayList()); 2.set转listList list = new ArrayList(new HashSet()) ...

  5. c++中string类对象和字符数组之间的相互转换

    string类在c++中是一个模板类,位于名字空间std中,注意这里不是string.h,string.h是C字符串头文件. 将string类型转换为字符数组char arr[10];string s ...

  6. String,Integer,int类型之间的相互转换

    String, Integer, int 三种类型之间可以两两进行转换 1. 基本数据类型到包装数据类型的转换 int -> Integer (两种方法) Integer it1 = new I ...

  7. string,const char*,char*之间的相互转换

    1. string转const char* string s = "abc"; const char* c_s = s.c_str(); 2. const char*转string ...

  8. Java中字符串和byte数组之间的相互转换

    1.将字符转换成byte数组 String str = "罗长"; byte[] sb = str.getBytes(); 2.将byte数组转换成字符 byte[] b={(by ...

  9. 【python】列表与数组之间的相互转换

    安装numpy pip3 install numpy 列表转数组 np.array() import numpy as np a = [1, 2, 3] b = np.array(a) 列表转数组 a ...

随机推荐

  1. spring boot 中@Mapper和@Repository的区别

    0--前言 @Mapper和@Repository是常用的两个注解,两者都是用在dao上,两者功能差不多,容易混淆,有必要清楚其细微区别: 1--区别 @Repository需要在Spring中配置扫 ...

  2. webpack4.0安装及使用(一)

    前言  1.什么是webpack 本质上,webpack 是一个现代 JavaScript 应用程序的静态模块打包器(module bundler).当 webpack 处理应用程序时,它会递归地构建 ...

  3. #华为云·寻找黑马程序员#微服务-你真的懂 Yaml 吗?

    在Java 的世界里,配置的事情都交给了 Properties,要追溯起来这个模块还是从古老的JDK1.0 就开始了的. "天哪,这可是20年前的东西了,我居然还在用 Properties. ...

  4. 移动前端不得不了解的HTML5 head 头标签 —— HTML基本的头部标签

    HTML的头部内容特别多,有针对SEO的头部信息,也有针对移动设备的头部信息.而且各个浏览器内核以及各个国内浏览器厂商都有些自己的标签元素,有很多差异性.移动端的工作已经越来越成为前端工作的重要内容, ...

  5. openstack学习之neutron ml2初始化代码分析

    这里没有 去详细考虑neutron server怎么初始化的,而是直接从加载插件的地方开始分析.首先我们看下下面这个文件. Neutron/api/v2/router.py class APIRout ...

  6. SpringBoot与JPA

    JPA是什么 JPA是Java Persistence API的简称,中文名Java持久层API,是JDK 5.0注解或XML描述对象-关系表的映射关系,并将运行期的实体对象持久化到数据库中. JPA ...

  7. I_want_all 2019训练记录

    Team members StarHai binarycopycode Fly_White Caution 读题 数组第一维的访问速度比其他维速度快. 清空数组 乘法运算取模里面涉及到减法注意变为负数 ...

  8. 新版FPC摄像头测评 OV7725 OV7670 OV9650 OV9655 OV5640 OV5642 OV2640 OV3640 MT9D112

    新版FPC摄像头测评 OV7725 OV7670 OV9650 OV9655 OV5640 OV5642 OV2640 OV3640 MT9D112 最新制样新版FPC摄像头板卡,先看看结构尺寸 再瞧 ...

  9. php 温故而知新 好久不用 又得继续学习下

    1.php注释:/* */.//.#等三种方式2.echo:向浏览器输出字符串,echo其实是一个函数:返回值:无3.print:向浏览器输出字符串,它也是一个函数:返回值:整型.           ...

  10. IP,MAC

    MAC寻址与IP寻址 两者是协议上的区分,MAC地址是网卡的物理地址,是提供二层交换机转发数据的,交换机会在自己的内部形成一个MAC地址表,然后根据这个表转发数据包:再者,如果说网络规模大一点的话,机 ...