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. 微信小程序——事件冒泡

    在微信小程序的事件分为冒泡事件和非冒泡事件: 冒泡事件:当一个组件上的事件被触发后,该事件会向父节点传递. 非冒泡事件:当一个组件上的事件被触发后,该事件不会向父节点传递. WXML的冒泡事件列表: ...

  2. 洛谷 P2388 阶乘之乘 题解

    本蒟蒻又来发题解了QwQ; 看到这个题目,本蒟蒻第一眼就想写打个暴力: 嗯,坏习惯: 但是,动动脑子想一想就知道,普通的的暴力是过不了的: 但是,身为蒟蒻的我,也想不出什么高级的数学方法来优化: 好, ...

  3. CSS3(1)---圆角边框、边框阴影

    CSS3(1)---圆角边框.边框阴影 CSS3可以简单理解成是CSS的增强版,它的优点在于不仅有利于开发与维护,还能提高网站的性能. 一.圆角边框 圆角在实际开放过程中,还是蛮常见的.以前基本是通过 ...

  4. LightOj-1030 Discovering Gold (期望DP)

    You are in a cave, a long cave! The cave can be represented by a 1 x N grid. Each cell of the cave c ...

  5. Node笔记 - process.cwd() 和 __dirname 的区别

    process.cwd() 返回工作目录  __dirname 返回脚本所在的目录位置 单看概念觉得都差不多,有种似懂非懂的感觉,那么接下用一个简单易懂的例子来理解下这两者的区别,在此之前先看一个方法 ...

  6. 分享和探讨——如何测试Java类的线程安全性?

    缺乏线程安全性导致的问题很难调试,因为它们是零星的,几乎不可能有意复制.你如何测试对象以确保它们是线程安全的? 我在最近的学习中和优锐课老师谈到了这个问题.现在,是时候以书面形式进行解释了.线程安全是 ...

  7. cs5642-v3各配置文件测试图片对比

    寄存器功能强大,可以配置很多参数,每个参数出来的图像都不同 我们以cs5642-v3的两个配置进行了对比测试 测试准备 配置文件:ov5642_960p_RAW和OV5642_YUV_VGA 测试摄像 ...

  8. 基于iCamera测试AR0134 960p 全局快门相机模块小结

    基于iCamera测试AR0134 960p 全局快门相机模块小结 首先看看此模块的特性 AR0134 全局曝光 CMOS模块 1280*960像素 5.3 V/lux-sec 摄像头模块实物靓照(上 ...

  9. harbor部署常见的错误

    总结部署harbor过程所遇到的一些坑   1:在使用docker push镜像的时候提示:denied: requested access to the resource is denied,用户和 ...

  10. 在C#中将对象序列化成Json格式

    在C#中将对象转换为Json格式的字符串. //匿名对象 var dataObj = new { Number = 1, Name = "Json" }; //将返回的时间格式解析 ...