trim(); 上面的程序的作用是将字符串strWithSpace前后的空格去掉,输出"this is a string with space"。 trimStart(); 用于删除字符串前面的空格 上面的程序的作用是将字符串strWithSpace前面的空格去掉,输入"this is a string with space " trimEnd(); 上面的程序输出" this is a string with space" Trim()方法还可以删除指定的字符串
{
string strWithSpace = " this is a string with space ";
string strWithoutSpace = strWithSpace.Trim();
Console.WriteLine(strWithoutSpace);
Console.ReadKey();
}
{
string strWithSpace = " this is a string with space ";
string strWithoutSpace = strWithSpace.TrimStart();
Console.WriteLine(strWithoutSpace);
Console.ReadKey();
}
{
string strWithSpace = " this is a string with space ";
string strWithoutSpace = strWithSpace.TrimEnd();
Console.WriteLine(strWithoutSpace);
Console.ReadKey();
}删除指定的字符
C#中Trim的使用
精选 转载 void DelSpace()
void DelSpace()
void DelSpace()
上一篇:c#获得客户端来源URL
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
C#中WebBrowser的使用
网页与应用程序的交互不外乎是网页上点击某链接,或通过其它途径,比如表单提交等,使浏览器导航至新的链接,所以我通过BeforeNavigate
c# 开发语言 控件 html System
















