I believe you want sec_list = { 56 }
.
int[] first_list = { 1, 10, 12, 20 };
int[] sec_list = { 1, 10, 12, 20, 56 };
sec_list = sec_list.Except(first_list).ToArray();
Question
I want to remove same value from two var variable, This is what i have tried.
var first_list = [1,10,12,20] ;
var sec_list = [1,10,12,20,56];
sec_list.RemoveAll(first_list.Contains);
But it' snot working, values are not removed.
This is the expected result
sec_list = [56]
Solution
I believe you want sec_list = { 56 }
.
int[] first_list = { 1, 10, 12, 20 };
int[] sec_list = { 1, 10, 12, 20, 56 };
sec_list = sec_list.Except(first_list).ToArray();
OTHER TIPS
Try below code
int[] first_list = { 1, 10, 12, 20 };
int[] sec_list = { 1, 10, 12, 20, 56 };
var list = sec_list.Except(first_list);
sec_list = list.ToArray();