Skip to content

Instantly share code, notes, and snippets.

@longtth
Last active August 29, 2018 03:52
Show Gist options
  • Select an option

  • Save longtth/d7f1a6d058b50294ecf5f463142564b8 to your computer and use it in GitHub Desktop.

Select an option

Save longtth/d7f1a6d058b50294ecf5f463142564b8 to your computer and use it in GitHub Desktop.
Lọc một list khỏi 1 list khác

You can use Except:

List<car> list1 = GetTheList();
List<car> list2 = GetSomeOtherList();
List<car> result = list2.Except(list1).ToList();

You probably don't even need those temporary variables:

List<car> result = GetSomeOtherList().Except(GetTheList()).ToList();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment