Results 1 to 2 of 2

Thread: [2.0] C# Combining Collections Using AND

  1. #1

    Thread Starter
    Addicted Member señorbadger's Avatar
    Join Date
    Oct 2003
    Location
    Mud pools of wellingborough
    Posts
    193

    Question [2.0] C# Combining Collections Using AND

    Hello, I think this is more of a maths issue but here goes...

    I am trying to write a method where if i pass in a collection of a collection of "Customer" objects it will compare them by ID number to return a colleciton of objects using (AND) ie only if the ID number appears in all of them.

    Example expected

    Input:

    clsCustomer[][]
    |
    |---------- clsCustomer[]
    | |
    | |----- clsCustomer {ID = 1; FORENAME = "BOB"...}
    | |----- clsCustomer {ID = 2; FORENAME = "BILL"...}
    | |----- clsCustomer {ID = 3; FORENAME = "JOHN"...}
    |
    |---------- clsCustomer[]
    | |
    | |----- clsCustomer {ID = 1; FORENAME = "BOB"...}
    | |----- clsCustomer {ID = 2; FORENAME = "BILL"...}
    | |----- clsCustomer {ID = 4; FORENAME = "Hannah"...}
    | |----- clsCustomer {ID = 3; FORENAME = "JOHN"...}
    |
    |---------- clsCustomer[]
    | |
    | |----- clsCustomer {ID = 1; FORENAME = "BOB"...}
    | |----- clsCustomer {ID = 4; FORENAME = "Hannah"...}
    | |----- clsCustomer {ID = 5; FORENAME = "Vicky"...}
    | |----- clsCustomer {ID = 3; FORENAME = "JOHN"...}

    If this was fed into the method the collection below would be returned

    clsCustomer[]

    clsCustomer {ID = 1; FORENAME = "BOB"...}
    clsCustomer {ID = 3; FORENAME = "JOHN"...}

    because they appear in all of the input arrays

    Any help would be appriciated, source code would be handy

    Thanks all
    Last edited by señorbadger; Apr 26th, 2006 at 03:06 AM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2.0] C# Combining Collections Using AND

    An array and a collection are two different things, so you should be careful with your terminology. From your use of the square brackets it would seem that you are using arrays. Is that the case, because they are different types and thus have different properties and methods and thus will have to be treated differently?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width