简体   繁体   中英

Remove strings from string A that are in array B

I have array A and Array B , I want to get as result A\\B (to get only the strings that in A but not in B).

Of course I can do two for loops and do it , but is there some more nice way to do so ?

Thanks for help , i use .net3.5

You can use LINQ:

var difference = A.Except(B);

This uses a HashSet and will be substantially faster than nested for loops for large sets.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM