1 Replace
string sayHello = "Hello World!"; Console.WriteLine(sayHello); sayHello = sayHello.Replace("Hello", "张涛"); Console.WriteLine(sayHello); Hello World! 张涛 World!
2.ToLower() 全部小写
ToUpper()全部大写
3.Contains
string songLyrics = "You say goodbye, and I say hello"; Console.WriteLine(songLyrics.Contains("goodbye")); Console.WriteLine(songLyrics.Contains("greetings")); True False string songLyrics = "You say goodbye, and I say hello"; Console.WriteLine(songLyrics.StartsWith("You")); Console.WriteLine(songLyrics.StartsWith("goodbye")); Console.WriteLine(songLyrics.EndsWith("hello")); Console.WriteLine(songLyrics.EndsWith("goodbye")); True False True False