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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:39:58+00:00 2026-05-10T23:39:58+00:00

The Version class in .Net does not implement the CompareTo interface as I would

  • 0

The Version class in .Net does not implement the CompareTo interface as I would expect, it seems to handle the compare alphanumerically instead of comparing the four numbers. Maybe not a bug, but a ‘feature’.

Can anyone shine a light on why the compare (and also the standard <, = and > operators) do not work as I would expect below?

    Dim MainVersion As New Version('1.1.3251.4029')     Dim Ver_Low As New Version('1.1')     Dim Ver_Same As New Version('1.1.3251.4029')     Dim Ver_High As New Version('1.1.5.0')      ' CompareTo here yields 1 which is expected as MainVersion is greater than Ver_Low.     MessageBox.Show(String.Format('{0}.CompareTo({1}) = {2}', MainVersion.ToString(), Ver_Low.ToString(), MainVersion.CompareTo(Ver_Low).ToString()))      ' CompareTo here yields 0 which is expected as MainVersion and Ver_Same are the same.     MessageBox.Show(String.Format('{0}.CompareTo({1}) = {2}', MainVersion.ToString(), Ver_Same.ToString(), MainVersion.CompareTo(Ver_Same).ToString()))      ' **** Issue here **** CompareTo here yields 1 which is NOT expected as MainVersion is less than Ver_High.     MessageBox.Show(String.Format('{0}.CompareTo({1}) = {2}', MainVersion.ToString(), Ver_High.ToString(), MainVersion.CompareTo(Ver_High).ToString())) 

I know people have done their own manual workarounds for this, I’d like to know if this is by design or it should work and I might be doing something dumb.

Thanks in advance

Ryan

Update: I was doing something subtly dumb and treating them in the same was as IP addresses. For example; 1.1.3023.5364 is greater than 1.1.5 but 1.1.3023.5364 is < than 1.1.5000.

  • 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. 2026-05-10T23:39:59+00:00Added an answer on May 10, 2026 at 11:39 pm

    No, it’s comparing the four parts, treating each as a number. Which is the bigger number: 5 or 3251? Surely it’s 3251. Therefore version 1.1.3251.* is ‘newer’ (i.e. greater) than 1.1.5.*.

    If you’ve got 1.1.3251 coming before 1.1.5, then you’re effectively using a single number (the ‘build’ part) as a sequence of digits. That’s a mistake.

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

Sidebar

Ask A Question

Stats

  • Questions 100k
  • Answers 100k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer When the HtmlHelper render itself it checks if there is… May 11, 2026 at 7:55 pm
  • Editorial Team
    Editorial Team added an answer It is very possible to have multiple versions of glibc… May 11, 2026 at 7:55 pm
  • Editorial Team
    Editorial Team added an answer If you're asking how to map them through a mapping… May 11, 2026 at 7:55 pm

Related Questions

I'm trying to implement an HTML Parsing web service as described in Chapter 23
Are there any tools that auto-generate the hibernate POJOs by gathering information from the
I've looked at the ReaderWriterLock in .NET 2.0 and the ReaderWriterLockSlim in .NET 3.5,
On a class library project, I set the Start Action on the Debug tab

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.