List<>与string[]以及List<>与string

List<> convert to string[]

List<string> list=new List<string>();

string str=list.ToArray();

String[] convert to List<>

string[] str={"str1","str2","str3"};

List<string> list=new List<string>(str);

List<> convert to String

List<string> list=new List<string>();

string str=String.Join(";",list.ToArray());


再添加个List<>去重复方法

List<String> list=new List<string>();

list.Add("test1");

list.Add("test1");

list.Add("test2");

list.Add("test2");

System.Collections.Generic.HashSet<string> h = new System.Collections.Generic.HashSet<string>(list);

list.clear();

list.AddRange(h);

 

你可能感兴趣的:(String)