c# - 删除两个字符串之间的点

标签 c#

有没有办法去掉两个字符串之间的点?

我有两个字符串:Linkw2.IDLinkw2.t169ID

我希望它们是 Linkw2IDLinkw2t169ID

我正在使用 string substring = InpParam.Substring(0, InpParam.IndexOf(".")); 但它会返回 Linkw2Linkw2

最佳答案

您可以使用 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/

相关文章:

c# - 使用规范模式

c# - const Enum 避免循环定义的最佳实践命名约定

c# - 如何将参数传递给 C# 中的公共(public)类?

c# - 如何使用 protobuf-net 处理 .proto 文件

c# - 发布 .NET c# 应用程序时出错

c# - Server.MapPath() 返回与 DirectoryInfo 一起使用时不存在的路径

c# - 将 UTF-16 字节数组编码为字符串字符 C# .NET

c# - 如何将用户定义类型的数组传递给存储过程

c# - 请求参数不在 POST 请求中传输

c# - 如何使 Redis 缓存在部署在 IIS Express 上但在本地主机上工作的 asp.net 核心 Web 上工作