Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Unique record from one list that not match with other?

Tags:

c#

list

Hi I have two list I want to get Unique record from first list that not match with other.

Example

List = [1,2,3,4,5,6,7]
List = [1,2,3,4,5,8]

According to my need output should be like this [6,7].

Please suggest me how it will be done?

like image 783
Pankaj Mishra Avatar asked Nov 24 '25 23:11

Pankaj Mishra


2 Answers

IEnumerable<int> result = list1.Except(list2);
like image 181
SLaks Avatar answered Nov 27 '25 13:11

SLaks


You can use Except

like image 26
Ta01 Avatar answered Nov 27 '25 13:11

Ta01