string s1 = "One Two Three Four";
string sx = (string)s1.Clone(); //s1复制到sx
Console.WriteLine(Object.ReferenceEquals(s1, sx)); //True:相同引用
sx += “ Five”;//sx修改
Console.WriteLine(Object.ReferenceEquals(s1, sx)); // False:不同的引用
Console.WriteLine(sx); // 显示"One Two Three Four Five" ToString() method Another common way to create a string is to call the ToString() method on an object and assign the result to astring variable.int myInteger = 5;
string integerString = myInteger.ToString();
split函数 用来过滤字符串中的字符
class Program { static void Main(string[] args) { string words = "one,twot,hree,four,five"; string[] splitedString = words.Split(','); foreach (string s in splitedString) { Console.Write(s); } }输出结果为
其中的“,”被过滤掉了。转载于:https://www.cnblogs.com/GSONG/p/4440001.html