C# 数组、集合和字符串之间的相互转换


字符串转为数组

string str = "1,2,3,4";

string[] strArr = str.Split(',');

 

数组转为字符串

string[] scoresArr = { "1", "2", "3", "4", "5" };
string scores = string.Join(",", scoresArr);

 

字符串转为集合

string str = "a,b,c";

List<string> strList = str.Split(',').ToList();

 

集合转为字符串

List<string> abcList = new List<string> { "a", "b", "c", "d" };
string str = string.Join(",", abcList);


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM