如何修剪字符之间的空白 [英] How to trim whitespace between characters
问题描述
如何删除字符之间的空格在C#?
TRIM()
可用于去除空空间的字符串的开头以及末尾。例如C夏普.Trim()
结果C夏普
。
但如何使串入 您可以使用的与string.replace 法 如果您要删除所有空格字符(空格,制表符,换行符...) How to remove whitespaces between characters in c#? But how to make the string into You could use String.Replace method or if you want to remove all whitespace characters (space, tabs, line breaks...)
这篇关于如何修剪字符之间的空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! CSHARP
?我们可以用一个临时变量一起拔出使用每个
循环的空间或。但是,有没有内置的方法
C#(.NET Framework 3.5中)
来做到这一点像 TRIM()
<? / p>
字符串str =C夏普
海峡= str.Replace(,);
字符串str =C夏普
海峡= Regex.Replace(STR,@\s,);
Trim()
can be used to remove the empty spaces at the beginning of the string as well as at the end. For example " C Sharp ".Trim()
results "C Sharp"
.CSharp
? We can remove the space using a for
or a for each
loop along with a temporary variable. But is there any built in method in C#(.Net framework 3.5)
to do this like Trim()
?string str = "C Sharp";
str = str.Replace(" ", "");
string str = "C Sharp";
str = Regex.Replace(str, @"\s", "");