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 6688993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:28:03+00:00 2026-05-26T05:28:03+00:00

I have a list of objects, each with 2 relevant properties: ID and Name.

  • 0

I have a list of objects, each with 2 relevant properties: “ID” and “Name”. Lets call the list “lstOutcomes”.
I need to check the list for duplicates (meaning object1.ID = object2.ID, etc.) and set a flag (valid = false, or something) if there is at least one duplicate. Also, it would be nice to send a message to the user mentioning the “Name” of the object, when it fails.

I am sure I will need to use the Group By operator to do this, but I am not used to doing that in LINQ, and the examples out there are just not helping me. This article seems to be close to what i need, but not quite and it’s in C#.

Here is a starting stab at it…

Dim duplist = _
    (From o As objectType In lstOutcomes _
    Group o By o.ID Into g = Group _
    Let dups = g.Where(Function(h) g.Count > 1) _
    Order By dups Descending).ToArray

if duplist.count > 0 then
valid = false
end if

help?

  • 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. Editorial Team
    Editorial Team
    2026-05-26T05:28:03+00:00Added an answer on May 26, 2026 at 5:28 am

    The project is behind, I just hacked it together like this:

        ' For each outcome, if it is in the list of valid outcomes more than once, and it is not in the list of 
        ' duplicates, add it to the duplicates list.
        Dim lstDuplicates As New List(Of objectType)
        For Each outcome As objectType In lstOutcomes
            'declare a stable outcome variable
            Dim loutcome As objectType = outcome
            If lstOutcomes.Where(Function(o) o.ID = loutcome.ID).Count > 1 _
            AndAlso Not lstDuplicates.Where(Function(d) d.ID = loutcome.ID).Count > 0 Then
                lstDuplicates.Add(outcome)
            End If
        Next
        If lstDuplicates.Count > 0 Then
            valid = False
            sbErrors.Append("There cannot be multiple outcomes of any kind. The following " & lstDuplicates.Count & _
                            " outcomes are duplicates: ")
            For Each dup As objectType In lstDuplicates
                sbErrors.Append("""" & dup.Name & """" & " ")
            Next
            sbErrors.Append("." & vbNewLine)
        End If
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As input I have list of all objects where each object has properties: name
I have a list of Point objects, (each one with x,y properties) and would
I have these container objects (let's call them Container) in a list. Each of
I have a list of objects and each and every object in the list
I have a list of objects, each containing an Id, Code and Description. I
I have a list of objects. Each object has an integer quantity and a
I have a List, it has Foo objects, and each Foo has a start
I have two lists of objects. Each list is already sorted by a property
You have list of objects and each of them has an id property. Here's
I want to have a stl list of objects where each object contains two

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.