我想在"<img"
标记之前只获取数据。
我的代码如下:我如何完成它?
string body = row[2].ToString();
int num;
num = body.IndexOf("<img");
答案 0 :(得分:3)
// 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);
答案 1 :(得分:2)
string body = body.Substring(0, body.IndexOf("<img"));
答案 2 :(得分:1)
string interesting = body.Substring(0, num);