Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 182845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:00:41+00:00 2026-05-11T15:00:41+00:00

I have an array of arrays – information about selection in Excel using VSTO,

  • 0

I have an array of arrays – information about selection in Excel using VSTO, where each element means start and end selection position.

For example,

int[][] selection = { new int[] { 1 }, // column A new int[] { 6 }, // column F new int[] { 6 }, // column F new int[] { 8, 9 } // columns H:I new int[] { 8, 9 } // columns H:I new int[] { 12, 15 } // columns L:O }; 

Could you please help me to find a way, maybe using LINQ or Extension methods, to remove duplicated elements? I mean: F and F, H:I and H:I, etc.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T15:00:42+00:00Added an answer on May 11, 2026 at 3:00 pm

    If you want to use a pure LINQ/extension method solution, then you’ll need to define your own implementation of IEqualityComparer for arrays/sequences. (Unless I’m missing something obvious, there’s no pre-existing array or sequence comparer in the BCL). This isn’t terribly hard however – here’s an example of one that should do the job pretty well:

    public class SequenceEqualityComparer<T> : IEqualityComparer<IEnumerable<T>> {     public bool Equals(IEnumerable<T> x, IEnumerable<T> y)     {         return Enumerable.SequenceEqual(x, y);     }      // Probably not the best hash function for an ordered list, but it should do the job in most cases.     public int GetHashCode(IEnumerable<T> obj)     {         int hash = 0;         int i = 0;         foreach (var element in obj)             hash = unchecked((hash * 37 + hash) + (element.GetHashCode() << (i++ % 16)));         return hash;     } } 

    The advantage of this is that you can then simply call the following to remove any duplicate arrays.

    var result = selection.Distinct(new SequenceEqualityComparer<int>()).ToArray(); 

    Hope that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create an array of arrays. I have been using array_map(null,$a,$b,$c) to
I have an array ($configOptions) which contains some arrays. Each array ($option) in that
I am learning about arrays, and basically I have an array that collects a
I am using google maps api v3 and have an array of arrays object:
I have an array of arrays. The inner array is 16 slots, each with
I have an array of arrays, each array containing details of a scan by
I have an array of arrays that is currently printing each object in the
How to compare 2 arrays with each other? For example i have array(a, b,
I have an array that contains an array of arrays if that makes any
Hello frnds actually i have a array of arrays as given below:-` parrent array{

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.