我如何检查是否在另一个字符串存在字符串 [英] How can I check if a string exists in another string
本文介绍了我如何检查是否在另一个字符串存在字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
希望有人能帮助我。我刚学C#和我有一个简单的问题。
Hope somebody can help me. I am just learning C# and I have a simple question.
我有一个变量,我想检查是否在另一个字符串存在。类似
I have a variable and I would like to check if that exists in another string. Something like
if ( test contains "abc" ) {
}
有一个简单的方法在C#中做到这一点。
Is there an easy way to do this in C#
推荐答案
使用 String.Contains :
if (stringValue.Contains(anotherStringValue))
{
// Do Something //
}
这篇关于我如何检查是否在另一个字符串存在字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文