MLT
(MLT)
April 19, 2021, 6:13am
1
Hi i have a Dt and a arr_String with a list of values
i used for each item in arr_String
-> for each row in DT
-> if item.ToString.Contains(row("ID).toString)
-> Then True Else - False
In the above case i want only the unmatched row which is "ID- 3 " to come in the else case.
How to check the item with all the rows and returns only the unmatched on from the list?
Please help
Yoichi
(Yoichi)
April 19, 2021, 6:36am
2
Hi,
Hope the following helps you.
Or the following expression will also work if one or more rows exist in result.
filteredDt = dt.AsEnumerable.Where(Function(r) not r("List_Var").ToString.Contains(r("ID").toString)).CopyToDataTable
Regards,
MLT
(MLT)
April 19, 2021, 6:44am
3
Hi @Yoichi ,
Thanks for the suggestion but here lis_var does not belong to the datatable, its separate arr_String which contains a list of values.
I used
-> ->for each item in arr_String
-> for each row in DT
-> if item.ToString.Contains(row("ID).toString)
-> Then True Else - False
In the above case i want only the unmatched row which is "ID- 3 " to come in the else case.
Hello @MLT ,
You have two variables both are list,
you will have to use two for each,
for each row in dt.rows
for each str in arr_String
if row(“ID”).tostring.contains(str){
bool = True
StrID = Row(“ID”)
exit if
}
Else{
bool = False
}
if Not bool{
StrID = Row("ID")
}
Else{
do nothing
}
@MLT can you check above condition now?
Cheers,
Pankaj
Yoichi
(Yoichi)
April 19, 2021, 6:52am
5
Hi,
Can you try the following?
in this case, we don’t need outer for each.
Regards,
MLT
(MLT)
April 19, 2021, 6:54am
6
yes i used two for each loop.
since both the list are not in same order the condition returns false for all other values as well
for ex : ID -1 checks with List var - 5_A, 1_B, 4_C,2_D the condition returns false except 1_B
but i want to get only the unmatched ID - 3. Please help me with the condition
system
(system)
Closed
April 22, 2021, 7:26am
8
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.