C#----String的常用成员函数

			String str1 = "123114511";
			//比较
			Console.WriteLine (str1.CompareTo ("11344"));//1
			Console.WriteLine (String.Compare ("123", "345"));//-1
			Console.WriteLine (String.Equals ("2", "3"));//false
			               
			//索引
			Console.WriteLine (str1.Insert (2, "abc"));//12abc345
			Console.WriteLine (str1.IndexOf ("34"));//2,返回索引
			Console.WriteLine (str1.Trim ('1'));//删除前面的和后面的 1
			//C#中没有类似于C++中,string.at的函数	,但是可以直接用索引
			Console.WriteLine (str1 [3]);//2
			Console.WriteLine (str1.StartsWith ("123"));//是不是以123开头的,true

你可能感兴趣的:(C++,String)