C#之字符串

2021-04-19 11:29

阅读:659

标签:play   white   height   uri   nta   ring   alt   bsp   onclick   

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#之字符串

标签:play   white   height   uri   nta   ring   alt   bsp   onclick   

原文地址:https://www.cnblogs.com/zhangtaotqy/p/8671196.html


评论


亲,登录后才可以留言!