c# - 在达到特定字符之前如何获取字符?

标签 c#

我只想获取 "<img" 之前的数据标签。

我的代码如下:我怎样才能完成它?

string body = row[2].ToString();
int num;
num = body.IndexOf("<img");

最佳答案

// first find the index of your starting point
int start = body.IndexOf("<img");
// then find the index of your ending point
int end = body.IndexOf("\"", start);
// then retrieve that portion of the string
string goods = body.Substring(start, end - start);

关于c# - 在达到特定字符之前如何获取字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9852154/

相关文章:

c# - 以编程方式打开/关闭操作中心

c# - 如何获得第二个System.Thread.ThreadPool?

开罗库的 C# 包装器

c# - Net core通用存储库模式如何在编译时不知道其类型的情况下注入(inject)DbContext?

c# - 无法将存储在资源文件中的图像转换为 Asp.net 中的 Base64 字符串 [C#]

c# - 使用按位运算符验证 if 条件

c# - 我如何在基于 Android-Java 的应用程序中使用 DataTable。

c# - 如何路由 URI 中包含分号的请求

c# - 加载图像的 AJAX 性能

c# - 在 WPF 应用程序中,如何覆盖控制台关闭命令?