CSharp examples for Collection:List
Finding just the non-overlapping items in two lists
using System;/*from www.j a v a2s . c o m*/ using System.Collections.Generic; class Program { static void Main(string[] args) { Console.WriteLine("\nFinding just the non-overlapping items in two lists:"); Stack<int> stackOne = new Stack<int>(new int[] { 1, 2, 3, 4, 5, 6, 7, 8 }); Stack<int> stackTwo = new Stack<int>(new int[] { 2, 4, 6, 7, 8, 10, 12 }); HashSet<int> nonoverlapping = new HashSet<int>(stackOne); nonoverlapping.SymmetricExceptWith(stackTwo); foreach(int n in nonoverlapping) { Console.WriteLine(n.ToString()); } } }