有没有办法去掉两个字符串之间的点?
我有两个字符串:Linkw2.ID
和 Linkw2.t169ID
。
我希望它们是 Linkw2ID
、Linkw2t169ID
。
我正在使用 string substring = InpParam.Substring(0, InpParam.IndexOf("."));
但它会返回 Linkw2
和 Linkw2
。
最佳答案
您可以使用 String.Replace删除带有空字符串的点。如果要更改值,请不要忘记将结果分配回字符串。
This method does not modify the value of the current instance. Instead, it returns a new string in which all occurrences of oldValue are replaced by newValue, MSDN.
str = str.Replace(".", "");
Returns a new string in which all occurrences of a specified string in the current instance are replaced with another specified string, MSDN
关于c# - 删除两个字符串之间的点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21380474/