Tech Off Post

Single Post Permalink

View Thread: How can I combine 2 ObservableCollections side by side?
  • User profile image
    Sathyaish Chakravarthy


    You can copy them to HashSet<T> and then do all the possible Set theory operations on them like Union, Intersection, etc. without writing the code for it yourself.

    HashSet<T> has a parameterized constructor that accepts an IEnumerable<T>, so you can copy the data easily.

    HashSet<Foo> hashSet1 = new HashSet<Foo>(myObservableCollection1);
    HashSet<Foo> hashSet2 = new HashSet<Foo>(myObservableCollection2);


    and so on.