String常见属性方法
1.String.Join
string[] s = { "我", "爱", "中","国" }; string s1=String.Join(" ",s); Console.WriteLine(s1); //输出:我 爱 中 国 Console.WriteLine(s1.Length);//长度为7
2.将字符数组转为字符串
char[] letters = new char[] { 'a','b','c' }; string str = new string(letters); ////通过使用 string 构造函数 Console.WriteLine(str);//输出 abc
将字符串转为字符数组
string s5 = "gbd"; char [] array=s5.ToCharArray(); Console.WriteLine(array[0]);
3.String.Fomat
DateTime dateTime = new DateTime(2020,07,31,14,12,20); string aa = string.Format("{0:t} {0:d}", dateTime); Console.WriteLine(aa);//输出 14:12 2020/7/31
4.String.Split('','')
string str1 = "abc,123,ABC" ; string[] a0 = s1.Split(',',';');