检查包含特定字符串的数组列表的方法 [英] Method to check array list containing specific string
本文介绍了检查包含特定字符串的数组列表的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个ArrayList,它从数据库中导入记录.是否有任何方法可以检查arrayList是否包含我想与另一个列表(即api)匹配的schname?
I have an ArrayList that import records from a database. Is there any method to check whether the arrayList contains schname that i want to match to another list which is an api?
List<PrimaryClass> primaryList = new List<PrimaryClass>(e.Result);
PrimaryClass sc = new PrimaryClass();
foreach (string item in str)
{
for (int a = 0; a <= e.Result.Count - 1; a++)
{
string schname = e.Result.ElementAt(a).PrimarySchool;
string tophonour = e.Result.ElementAt(a).TopHonour;
string cca = e.Result.ElementAt(a).Cca;
string topstudent = e.Result.ElementAt(a).TopStudent;
string topaggregate = e.Result.ElementAt(a).TopAggregate;
string topimage = e.Result.ElementAt(a).TopImage;
if (item.Contains(schname))
{
}
}
}
这是我到目前为止提出的,请更正我可能犯的任何错误.谢谢.
This is what I have come up with so far, kindly correct any errors that I might have committed. Thanks.
推荐答案
尝试一下
foreach( string row in arrayList){
if(row.contains(searchString)){
//put your code here.
}
}
这篇关于检查包含特定字符串的数组列表的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文