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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:06:57+00:00 2026-05-20T21:06:57+00:00

i have the following problem and I cannot figure out where it comes from.

  • 0

i have the following problem and I cannot figure out where it comes from. I would appreciate help very much.

The code:

List<Point> lst = new List<Point>();
lst.Add(new Point(0, -2));
lst.Add(new Point(-1, -2));

lst.Sort(delegate (Point x,Point y)
{
    if (x.X == 0)
        return -1;
    else if (y.X == 0)
        return 1;
    else
    {
        double retVal1 = x.Y * 1.0 / -x.X;
        double retVal2 = y.Y * 1.0 / -y.X;
        int retVal = -Math.Sign(retVal1 - retVal2);
        return retVal;
    }
});

If executed, I recieve an ArgumentException saying that IComparer doesn’t not return 0(null). However, it actually cannot return anything else but -1, 0 and 1, or?

Thank you very much for your help!

Ah, btw i’m using .NET 3.5

  • 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-20T21:06:58+00:00Added an answer on May 20, 2026 at 9:06 pm

    Actually the error message says: IComparer (or the IComparable methods it relies upon) did not return zero when Array.Sort called x. CompareTo(x). x: ” x’s type: ‘Point’ The IComparer: ‘System.Array+FunctorComparer`1[System.Drawing.Point]’.

    You must return 0 if the objects are identical:

        lst.Sort(delegate(Point x, Point y) {
            if (x.X == y.X && x.Y == y.Y) { // you are missing this
                return 0;
            }
            if (x.X == 0)
                return -1;
            else if (y.X == 0)
                return 1;
            else {
                double retVal1 = x.Y * 1.0 / -x.X;
                double retVal2 = y.Y * 1.0 / -y.X;
                int retVal = -Math.Sign(retVal1 - retVal2);
                return retVal;
            }
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have run into this problem multiple times, and I cannot figure out why
I have following problem, Code: String a=Yeahh, I have no a idea what's happening
I have another strange bug which I cannot figure out. I try to create
I have a problem in getting some data out from Cassandra using c# and
This might have a simple answer, however I cannot figure out the correct syntax.
I have the following Python (3.2) code: from pygame import * class Application: def
I am having a problem that I cannot figure out. I am using the
I am new to Crystal Report and I have a problem I cannot figure
I have a tiny problem with NHibernate and I can't figure out why. Every
I have following problem: I have built a tabbar application with 4 tabs. I

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.