c# - c#中的字符串插入问题

标签 c# .net asp.net string

我正在尝试在 C# 字符串的位置插入一个字符串,但失败了

这是片段。

  if(strCellContent.Contains("<"))
   {
         int pos = strCellContent.IndexOf("<");
         strCellContent.Insert(pos,"&lt;");
   }

请告诉我解决方法

最佳答案

返回值包含您想要的新字符串。

strCellContent = strCellContent.Insert(pos,"&lt;");

关于c# - c#中的字符串插入问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5401869/

相关文章:

c# - 反序列化到列表

c# - MVC Controller 的操作中的异步/等待

c# - WebApi Put如何从指定的属性中告诉未指定的属性设置为null?

asp.net - IIS7 ASP.NET 进程内 session 在应用程序回收后不会丢失

c# - 按两个值分组并计算第三个值

.net - 在 VB.net 中以表格形式显示 PDF

c# - SQL Server CLR 集成未按预期调用系统时间

c# - FileSystemWatcher - 只读属性的更改事件

.net - ASP.NET 检测 SVG 功能服务器端

javascript - 检查是否启用了 Javascript,如果未使用 asp 自定义控件,则显示一条消息