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. 谷歌地图 API 开发之获取坐标以及街道详情

    自己的项目中有获取当前点击的坐标经纬度或者获取当前街道的信息的需求.估计这个对于新手来说,还是比较麻烦的,因为从官网上找这个也并不是很好找,要找好久的,运气好的可能会一下子找到. 献上自己写的测试案例 ...

  2. 【直播分享】实现LOL小地图英雄头像分析案例【华为云分享】

    直播介绍: 当今时代是人工智能高速发展的时代,深度学习已经渗透入经济.工业.军事.娱乐等各各领域的角落.近年来AlphaGo击败李世石更是使得人工智能技术家喻户晓.人工智能在游戏领域的开发依然不断进步 ...

  3. 【并发技术16】线程同步工具Exchanger的使用

    如果两个线程在运行过程中需要交换彼此的信息,比如一个数据或者使用的空间,就需要用到 Exchanger 这个类,Exchanger 为线程交换信息提供了非常方便的途径,它可以作为两个线程交换对象的同步 ...

  4. 更适合Pythoner的标记语言Yaml学习总结

    pythonic的标记语言 之前总结过一篇关于小数据存储文件大比拼,当时着重介绍了json,因为它在各类编程语言的通用性较强.但今天,我想给大家介绍一款更加适合pythoner使用的语言Yaml. Y ...

  5. SpringBoot整合freemarker模板

    一.目录展示 二.导入依赖 三.application.properties配置文件 四.在src/main/resource/templates文件夹中创建HelloFreeMarker.ftl文件 ...

  6. Apache服务——个人用户主页功能

    使用Apache服务部署静态网站(二) 个人用户主页功能 Apache服务程序中有个默认未开启的个人用户主页功能,能够为所有系统内的用户生成个人网站,确实很实用哦~ 第1步:开启个人用户主页功能: [ ...

  7. gitlab 命令使用

    利用 rm -rf 误删除文件夹, 恢复的办法(注意 要 提前备份或提交 其他新改变的代码, 否则执行下面的命令会让之前的新代码全部消失): git status git reset HEAD \* ...

  8. nmon脚本——对Linux服务器的监控

    继服务器被挖之后,我又开拓了另一个监控工具----nmon! Nmon可以很轻松的监控系统的CPU.内存.网络.硬盘.文件系统.NFS.高耗进程.资源和IBM Power系统的微分区的信息,还有专属的 ...

  9. vue 各种打包坑

    1,报错 Refused to load the image 'http://localhost:8080/favicon.ico' because it violates the following ...

  10. CSS_跳动的心

    详细教程CSS3 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> < ...