C#字符串string函数
本文提供全流程,中文翻译。
Chinar 坚持将简单的生活方式,带给世人!
(拥有更好的阅读体验 —— 高分辨率用户请根据需求调整网页缩放比例) |
Chinar —— 心分享、心创新!
助力快速理解 C# string 字符串内置函数用法
为新手节省宝贵的时间,避免采坑! |
全文高清图片,点击即可放大观看 (很多人竟然不知道)
1
Info —— Main
![举个栗子黑白88]()
class Program
{
static void Main(string[] args)
{
string str = "a";
int res = str.CompareTo("b");
Console.WriteLine(res);
str = "b";
res = str.CompareTo("a");
Console.WriteLine(res);
str = "b";
res = str.CompareTo("a");
Console.WriteLine(res);
Console.WriteLine("_________________________________比较________________________________________");
str = "www.unity.kim";
string newReplace = str.Replace('.', '-');
Console.WriteLine(newReplace);
Console.WriteLine("___________________________________替换______________________________________");
string[] strings = str.Split('.');
foreach (var s in strings)
{
Console.WriteLine(s);
}
Console.WriteLine("__________________________________拆分_______________________________________");
string newSubstring = str.Substring(4, 5);
Console.WriteLine(newSubstring);
newSubstring = str.Substring(4);
Console.WriteLine(newSubstring);
Console.WriteLine("__________________________________从某个位置截取字符串_______________________________________");
string strUp = str.ToUpper();
Console.WriteLine(strUp);
var strLow = str.ToLower();
Console.WriteLine(strLow);
Console.WriteLine("__________________________________大小写_______________________________________");
str = " www.unity.kim ";
string newTrim = str.Trim();
Console.WriteLine(str);
Console.WriteLine(newTrim);
Console.WriteLine("__________________________________去首位空格_______________________________________");
int num = str.IndexOf("unidty");
Console.WriteLine(num);
Console.ReadLine();
}
}
支持
May Be —— 搞开发,总有一天要做的事!
拥有自己的服务器,无需再找攻略!
Chinar 提供一站式教程,闭眼式创建!
为新手节省宝贵时间,避免采坑! |
先点击领取 —— 阿里全产品优惠券 (享受最低优惠)
1 —— 云服务器超全购买流程 (新手必备!)
2 —— 阿里ECS云服务器自定义配置 - 购买教程(新手必备!)
3—— Windows 服务器配置、运行、建站一条龙 !
4 —— Linux 服务器配置、运行、建站一条龙 !
Chinar
END
本博客为非营利性个人原创,除部分有明确署名的作品外,所刊登的所有作品的著作权均为本人所拥有,本人保留所有法定权利。违者必究
对于需要复制、转载、链接和传播博客文章或内容的,请及时和本博主进行联系,留言,Email: ichinar@icloud.com
对于经本博主明确授权和许可使用文章及内容的,使用时请注明文章或内容出处并注明网址、