【发布时间】:2015-10-17 02:28:40
【问题描述】:
我正在使用此代码检查字符串(oCode/ originalCode)是否存在于数组中(字符串由用户编写):
if (dic.cs.Any(code.Contains)) //dic.cs is in another class (cs is the array), the code variable is what I look for in the array
{
//I want to get the string was found in the array with the "Contains" function
}
我想通过Contains() 函数获取在数组中找到的字符串。
【问题讨论】:
-
使用
IndexOf方法。 -
什么是代码变量?你能给我们更多关于这里发生的事情的背景吗?但是,我确实尝试在下面回答。
-
没错,我会编辑...代码变量是我要搜索数组的字符串。