List<string>和string[]数组之间的相互转换,需要的朋友可以参考下
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[]数组之间的相互转换,需要的朋友可以参考下的更多相关文章
- C#中List〈string〉和string[]数组之间的相互转换
1,从System.String[]转到List<System.String> System.String[] str={"str","string" ...
- c# string 和 byte[]数组之间转换
在文件流读取和存储过程当中,经常涉及到byte[]数组形式存储数据,再此过程中也涉及到String类型字符串和byte[]的类型转换,下面我们举例说明一下. 现在有一个字符串: string str ...
- c++中几种常见的类型转换。int与string的转换,float与string的转换以及string和long类型之间的相互转换。to_string函数的实现和应用。
1.string转换为int a.采用标准库中atoi函数,对于float和龙类型也都有相应的标准库函数,比如浮点型atof(),long型atol(). 他的主要功能是将一个字符串转化为一个数字,在 ...
- list,set,map,数组之间的相互转换详细解析
1.list转setSet set = new HashSet(new ArrayList()); 2.set转listList list = new ArrayList(new HashSet()) ...
- c++中string类对象和字符数组之间的相互转换
string类在c++中是一个模板类,位于名字空间std中,注意这里不是string.h,string.h是C字符串头文件. 将string类型转换为字符数组char arr[10];string s ...
- String,Integer,int类型之间的相互转换
String, Integer, int 三种类型之间可以两两进行转换 1. 基本数据类型到包装数据类型的转换 int -> Integer (两种方法) Integer it1 = new I ...
- string,const char*,char*之间的相互转换
1. string转const char* string s = "abc"; const char* c_s = s.c_str(); 2. const char*转string ...
- Java中字符串和byte数组之间的相互转换
1.将字符转换成byte数组 String str = "罗长"; byte[] sb = str.getBytes(); 2.将byte数组转换成字符 byte[] b={(by ...
- 【python】列表与数组之间的相互转换
安装numpy pip3 install numpy 列表转数组 np.array() import numpy as np a = [1, 2, 3] b = np.array(a) 列表转数组 a ...
随机推荐
- Layui下拉3级联动
这里我就不给大家详细说明了直接附图: js代码: layui.use(['layer', 'form','xform','layer'], function () { var element = la ...
- 面试一个小公司,TPM相关概念
准备面试一个小公司,在面试邀请邮件中提出了这样一个要求(not required): ".. one item we will likely discuss with you is soft ...
- Python不再为字符集编码发愁,使用chardet轻松解决你的困扰。
欢迎添加华为云小助手微信(微信号:HWCloud002 或 HWCloud003),输入关键字"加群",加入华为云线上技术讨论群:输入关键字"最新活动",获取华 ...
- Web安全-之文件上传漏洞场景
1 上传漏洞危害介绍 上传是Web中最常见的功能,如果上传功能存在设计.编码缺陷,就容易形成上传漏洞,从而成为致命的安全问题,攻击者可以通过上传脚本木马,实现查看/篡改/删除源码和任意涂鸦网页,可 ...
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'ExtractAbstractServiceHandler' is defined
在利用 Spring 集成 thrift 时,报错如下: javax.servlet.ServletException: Servlet.init() for servlet search-nlp-s ...
- WARNING: Your kernel does not support swap limit capabilities. Limitation discarded.
利用vSphere调整各台虚拟机后,重新启动mesos,让其启动docker,并为每个container分配cpu和mem,但每次都有一个TASK_LOST. 查看mesos slave的log,发现 ...
- android 点击无效验证
背景 在写一个东西滑动删除列表的时候,出现了一个问题.我的需求是,左滑然后出现delete,然后点击delete,让该滑块消失. 我在点列表的第一行的时候,左滑,出现delete,点击删除,ok的,完 ...
- 2.4G芯片SI24R1可替代NRF24L01P
随着美金和原厂对价格的调控,NRF24L01P的价格越来越高,对终端制造的客户造成了不少的压力成本,但很多人又不原意花费更多的人力物力去重新改版. 小编今天就着重给大家介绍一款芯片,可以在不改板的情况 ...
- 28. 实现strStr() (双指针)
实现 strStr() 函数. 给定一个 haystack 字符串和一个 needle 字符串,在 haystack 字符串中找出 needle 字符串出现的第一个位置 (从0开始).如果不存在,则返 ...
- JS基础知识——变量类型和计算(一)
JS中使用typeof能得到的哪些类型? 何时使用===何时使用==? JS中有哪些内置函数? JS变量按照存储方式区分为哪些类型,描述其特点? 如何理解JSON? 知识点梳理 一.变量类型: (1) ...