C#中的字符串操作

一、字符串拼接

1.直接拼接

string a = "hello";
string b = "wrod";
string c = a + b;

2.使用string对象的Format方法连接

string.Format("@0@1", "hello", "word");

3.使用string对象的Concat方法连接

string.Concat("hello", "word");

二、空白字符去除

string a = " hello world ";
a.Trim();


你可能感兴趣的:(C#中的字符串操作)