c# - Get uniques elements -


i have

int[] array1 = { 1, 2, 3 }; int[] array2 = { 2, 3, 4 }; 

using var intersect = array1.intersect(array2);i got

2 3 

but need

  1   4 

can give me advice how can using linq?

array1.union(array2).except(array1.intersect(array2)) 

explanation:

  1. first calculate set union of 2 sequences: 1, 2, 3, 4
  2. you calculating intersection of sets: 2, 3
  3. you finding set difference between items , intersection: 1, 4

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -