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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:49:43+00:00 2026-05-23T06:49:43+00:00

One Generic list that contain Points say => List<Point> Now I need to filter

  • 0

One Generic list that contain Points say =>List<Point>

Now I need to filter points and store it in another List<Point> as per below condition and Using LINQ.

• At given Y value of Point

• Find Points with Maximum X values and Minimum X values.

NOTE:

Actually friends, I am looking for the LINQ query which performs above operation in just single query if possible.

Otherwise any best solution for above operation using LINQ,

EDIT:-
see my code here but i am looking for sort solution…..

               int givenY = 147;

                List<Point> listOfPointLocal = (from point in listOfPointMain
                        where point.Y == givenY
                        select point).ToList();

                var minX = listOfPointLocal.Min(p => p.X);
                var maxX = listOfPointLocal.Max(p => p.X);

                List<Point> listOfFilterdPoint = (from p in listOfPointLocal
                                         where p.X <= minX || p.X >= maxX
                                         select p).ToList();

Thanks…..

  • 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-23T06:49:43+00:00Added an answer on May 23, 2026 at 6:49 am

    With a little help from an extra class you can pass the list only once.

    public class MaxMin
    {
        public int max { get; set; }
        public int min { get; set; }
    }
    

    And then

    var points = new List<Point>() 
                    {
                        new Point(10, 10), 
                        new Point(15, 10), 
                        new Point(20, 10), 
                        new Point(42, 42), 
                        new Point(47, 11) 
                    };
    
    var maxmin = new MaxMin() { max = int.MinValue, min = int.MaxValue};
    maxmin = points.Where(p => p.Y == 10).
                        Aggregate(maxmin, (acc, next) =>
                        {
                            if (next.X > acc.max) acc.max = next.X;
                            if (next.X < acc.min) acc.min = next.X;
                            return acc;
                        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Fun with enums in C#. Take one generic list that is created to store
I need to write a generic procedure that set value for one column or
What I really like in C# are generic lists. A list that can contain
I'm creating a generic class and in one of the methods I need to
Here's the situation: We have some generic graphics code that we use for one
Classic ASP had 'server side includes' so that one could easily design a generic
I currently have a class that uses the KeyValuePair with List to store a
So I am working with WCF and my services return types that contain generic
I have a DataTable (or Generic List) that I want to bind to 2
I have a generic class that has one type parameter (T). I needed to

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.