码迷,mamicode.com
首页 > Windows程序 > 详细

C#之字符串

时间:2018-03-29 19:07:02      阅读:243      评论:0      收藏:0      [点我收藏+]

标签: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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!