1. 程式人生 > >C#之字符串

C#之字符串

say courier pre 分享圖片 圖片 and ola gpo start

1 Replace

技術分享圖片
string sayHello = "Hello World!";
Console.WriteLine(sayHello);
sayHello = sayHello.Replace("Hello", "張濤");
Console.WriteLine(sayHello);

Hello World!
張濤 World!
Replace

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
Contains()



C#之字符串