c# List<int> 转 string 以及 string [] 转 List<int>
2016-08-21 11:15
549 查看
List<int> 转 string :
list<int>: 1,2,3,4,5,6,7 转换成字符串:“1,2,3,4,5,6,7”
string [b][b]转[/b] [b]List<int>[/b]:[/b]
List<string> 转 List<int>
List<int> 转List<string>
C#中string[]数组和list<string>:
从List<System.String>转到System.String[]
list<int>: 1,2,3,4,5,6,7 转换成字符串:“1,2,3,4,5,6,7”
List<int> list= new List<int>() { 1, 2, 3, 4, 5, 6, 7 }; string depaid = string.Join(",", list);
string [b][b]转[/b] [b]List<int>[/b]:[/b]
string s = "1, 2, 3"; List<string> list = new List<string>(s.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries)); List<string> list = new List<string>(s.Split(','));//或者
List<string> 转 List<int>
var listOfStrings =(new[]{"4","5","6"}).ToList(); var listOfInts = listOfStrings.Select<string,int>(q =>Convert.ToInt32(q));
List<int> 转List<string>
List<int> l1 = new List<int>(new int[] { 1,2,3 } ); List<string> l2 = l1.ConvertAll<string>(x => x.ToString());
C#中string[]数组和list<string>:
System.String[] str={"str","string","abc"}; List<System.String> listS=new List<System.String>(str);
从List<System.String>转到System.String[]
List<System.String> listS=new List<System.String>(); listS.Add("str"); listS.Add("hello"); System.String[] str=listS.ToArray();
相关文章推荐
- C# Task 用法
- C# Task 用法
- C#中的lock关键字
- C#基本程序结构
- Visual studio 2015 C# 快速using,快捷键修改
- 《C#高级编程》读书笔记(十五):任务、线程和同步之二 任务
- C#入门9.12——类的封装
- C#预编译符
- c# 读取mck码
- 《C#高级编程》读书笔记(十五):任务、线程和同步之一 Parallel类
- c#之Datetimepicker格式的设置
- C# 关于readonly的使用说明
- C#中的局部类
- C# EventHandler and Delegate(委托的使用)
- C# EventHandler and Delegate(委托的使用)
- C#入门9.10——类的继承
- 使用命令行将类型生成到模块中
- C#实现的Win32控制台线程计时器功能示例
- C#实现的Windows剪贴板监视器功能实例【附demo源码下载】
- Github上十大C#开源项目排行榜