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

  • Home
  • SEARCH
  • 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 3341510
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:43:50+00:00 2026-05-18T00:43:50+00:00

NOTE: Before you read on or provide an answer, I know about Enumerable.Distinct ,

  • 0

NOTE: Before you read on or provide an answer, I know about Enumerable.Distinct, I am asking about specific language support for that method, not about the method itself.

I’ve always wondered why there is no distinct keyword in the C# LINQ keyword set so that I could write:

var items = distinct from x in y
            select x;

or

var items = from x in y
            select distinct x;

Anybody know why this wasn’t included or why it would be a bad idea to include it? It just feels cumbersome to me that I have to wrap the query just to call Distinct(); a distinct keyword would feel more natural.

NOTE: I know that the Distinct method has overrides to provide a comparer if that is required, but a keyword that uses the default comparer would be great. I could even imagine a distinct by keyword combination so that a comparison operator could be provided inline to the query.

  • 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-18T00:43:51+00:00Added an answer on May 18, 2026 at 12:43 am

    Charlie Calvert has a blog post ("Using Distinct and Avoiding Lambdas") discussing the issue. From the top of the post:

    1. Most query operators such as Select(), Where() and GroupBy() take something called a lambda as a parameter.
      2. Lambdas are difficult to write.
      3. Query expressions were created in large part to allow developers to use LINQ without having to learn the complex syntax associated with lambdas.
      4. A few query operators, such as Distinct(), do not take lambdas as parameters. As a result, they are easy to call.
      5. Query expressions were therefore not created for operators such as Distinct() that do not take lambdas.

    And also, from further down in the post:

    Query operators are method calls. In other words, there are methods in the LINQ API called Select(), Group(), Distinct(), etc. We don’t usually call these methods directly because they take lambdas as parameters, and many people find that lambdas are hard to understand. To help developers avoid the complex task of writing lambdas, the team invented query expressions, which are a "syntactic sugar" that sit on top of lambdas.

    TL;DR: There’s no distinct keyword for simplicity’s sake, since distinct does not take a lambda expression.

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

Sidebar

Related Questions

I'm certain this has been asked before-in other ways-please bear with me (for a
From php.net: <html> <?php /* This will give an error. Note the output *
I'm using the Python 2.5 that came with Mac OS X Snow Leopard (10.6).
For a very large site such as a Social Network (say Facebook), which method
I am implementing run length encoding using the GZipStream class in a C# winforms
I am reading a line from a file containing the names of people, first
I need to write a script to do the following: Monitor a queuing system,
i've created an C++ application using WinSck, which has a small (handles just a
I am trying to use this redirect_to redirect_to :controller => :note_categories, :action => :destroy,
There is a page demonstrates how to do it when using Elixir: http://beachcoder.wordpress.com/2007/05/02/adding-event-callbacks-to-sqlalchemyelixir-classes/ But

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.