c# - How to search through two list members? -
i have next class:
public class fixfirstduplicate { public string firstparam { get; set; } public string secondparam { get; set; } }
and list:
public static list<fixfirstduplicate> firstduplicate = new list<fixfirstduplicate>();
the list total of values firstparam , secondparam each correspond each other. it's table, first firstparam associated first secondparam , on.
then have:
list<string> conlines = new list<string>();
i want through conlines, , everytime string contains both firstparam , secondparam, perform method on string.
if doing 1 list, firstparam, utilize hashset, don't know how equivalent given have firstparam , secondparam
you need check if conlines
contains both firstparam
or secondparam
like:
var query = firstduplicate.where(r => conlines.contains(r.firstparam) && conlines.contains(r.secondparam));
edit: if want phone call method when find match , order of import can utilize simple foreach
loop like:
foreach (var item in firstduplicate) { string matchingstring = conlines.firstordefault(r => (r.indexof(item.firstparam)>= 0 && r.indexof(item.secondparam) >= 0) && (r.indexof(item.firstparam) < r.indexof(item.secondparam))); if(matchingstring != null) { //callyourmethod(matchingstring); } }
c# string visual-studio-2010 list hashset
No comments:
Post a Comment