【发布时间】:2017-12-10 22:31:50
【问题描述】:
也许这个问题有点混乱。 我将以更好的方式解释这一点 看这段代码
string myfirststring = "hello1,hello123,content";
string_2 = "ent";
if (myfirststring.Contains(string_2)){
Console.WriteLine("Yes! this is included in the 1 string");
//then check if string_2 is equal to the 3 element of 1 string: content
}
现在我想检查我包含的字符串“string_2”是否完全等于 myfirststring 的第 3 个元素:内容(在这种情况下,不是因为值是 ent 而不是 content 所以 ent != content) 那么我该如何检查呢?
【问题讨论】:
-
您的
myfirststring是否总是由,分隔? -
不,这是我真实项目中的一个例子,我有一个混淆的字符串,例如:--hello123--|-hello12--|-content-|---=
-
所以你的字符串是由带有任意数量连字符的管道符号分隔的?