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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:57:16+00:00 2026-05-27T13:57:16+00:00

I need to select distinct highways from a roads collection. I suppose I could

  • 0

I need to select distinct highways from a roads collection.

I suppose I could use LINQ for this.

I have (stub code)

  Dim roads As List(Of Roads) = myRegion.Roads
  Dim highways As New List(Of Highway)

  For Each road In roads
    If road.RoadType = RoadType.Highway Then
      highways.Add(DirectCast(road, Highway))
    End If
  Next ic

  ' Now I think sorting them by .Id and then remove duplicates '
  Dim myComparer As New HighwayByIdComparer
  highways.Sort(myComparer)

C# variants are accepted as well 😉

  • 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-27T13:57:17+00:00Added an answer on May 27, 2026 at 1:57 pm

    C#:

    return myRegion.Roads
        .Where(x => x.RoadType == RoadType.Highway)
        .DistinctBy(x => x.Id);
    

    (where DistinctBy is an extension method defined in Jon Skeet’s excellent MoreLINQ project)

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

Sidebar

Related Questions

I need some help please. I have this from my database: SELECT DISTINCT iwi.item
i need to select distinct value from a multiple union. I nee to use
i have sql statement like this SELECT DISTINCT results_sp_08.material_number FROM results_sp_08 INNER JOIN courses
I need to do this in nhibernate QueryOver: select distinct sc.* from [Security].[Commands] sc
I have this query: SELECT DISTINCT id, label FROM bbproduct_cust WHERE CUSTNO IN (SELECT
When I use this: SELECT DISTINCT id FROM table this works! but... when I
I need a select from table which does not have column that tells when
UPDATE IP SET (src_ip, vlan_id) = (SELECT DISTINCT src_ip, vlan_id FROM video_2) This command
I need help with a query to get distinct records from the table. SELECT
I have a set of tasks that I need to select distinct on (group

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.