Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我不确定实现相同目标的最佳方法是什么。我有逗号分隔的字符串,如
"sdf,sd,gth,ht,hjh,fds,nhgs"
我必须遍历整个字符串并将其与一个值匹配。如果该值不匹配,则在逗号后截断字符串的最后一部分并检查其余的整个字符串。
例如,如果值不匹配
然后截断逗号后的最后一个值并将该值与
"sdf,sd,gth,ht,hjh,fds"
这次。
继续遍历整个字符串,直到它与值不匹配。
最早在这方面的任何帮助都非常感谢。
var stringToMatch = "abc,def"; var testString = "abc,def,ghi,jkl"; bool matches = testString.StartsWith( stringToMatch );