473,325 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

String / Version Compare

MDB
Hello All,

Is there a easy way (meaning not spliting on each . ) to compare version
strings to find out which is greater?

For example 001.001.002 is greater than 001.001.001
Nov 16 '05 #1
5 13895
Remove the dots, convert to numeric and compare?
-Viksi

"MDB" wrote:
Hello All,

Is there a easy way (meaning not spliting on each . ) to compare version
strings to find out which is greater?

For example 001.001.002 is greater than 001.001.001

Nov 16 '05 #2
> Is there a easy way (meaning not spliting on each . ) to compare version
strings to find out which is greater?


use System.Version:

string s1 ="001.001.002", s2 = "001.001.001";
Version v1 = new Version(s1), v2 = new Version(s2);
if (v1 > v2)
MessageBox.Show("Yes");

Erik
Nov 16 '05 #3
MDB
Thanks
"Viksi" <Vi***@discussions.microsoft.com> wrote in message
news:04**********************************@microsof t.com...
Remove the dots, convert to numeric and compare?
-Viksi

"MDB" wrote:
Hello All,

Is there a easy way (meaning not spliting on each . ) to compare version
strings to find out which is greater?

For example 001.001.002 is greater than 001.001.001

Nov 16 '05 #4
MDB
Thanks! That is what I was looking for. I heard there was something like
this, just couldn't find it.
"Erik Frey" <er*******@hotmail.com> wrote in message
news:eS*************@TK2MSFTNGP11.phx.gbl...
Is there a easy way (meaning not spliting on each . ) to compare version
strings to find out which is greater?


use System.Version:

string s1 ="001.001.002", s2 = "001.001.001";
Version v1 = new Version(s1), v2 = new Version(s2);
if (v1 > v2)
MessageBox.Show("Yes");

Erik

Nov 16 '05 #5
tlhintoq
3,525 Expert 2GB
What was the reason this post/thread was reported (to all moderators and experts) ? Is there a problem or infraction?
Jan 19 '10 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Nasos Makriyiannis | last post by:
Hi, I'm new to XSL and I was wondering if there is a string-compare function available. I am using the following IF statement but it does not seem to be working: <xsl:if...
0
by: g | last post by:
Hi all. Maybe this question has been asked many times before, but I was not able to find any pointer. I apologize in advance, for it refers to a particular standard library implementation (GNU...
7
by: Erik Leunissen | last post by:
L.S. How can I make certain code parts be compiled conditionally, depending on the definition of a macro such as: #define VERSION "2.3" Is it all right to do things like:
46
by: yadurajj | last post by:
Hello i am newbie trying to learn C..I need to know about string comparisons in C, without using a library function,...recently I was asked this in an interview..I can write a small program but I...
10
by: Kevin | last post by:
Is there a way to search a string for the number of times a certain character shows up without having to write my own function? string var = "111-222-33.33-2" var.countchar(var) = 3
4
by: John Livermore | last post by:
In C# what is the best way to validate that a particular string entered by a user will actually convert to a date w/o using a try catch block or writing code to explicitly parse the string? Here...
6
by: anonieko | last post by:
Is this a long way to compare strings ignoring the case? if ( string.Compare(wsUri.Host, "localHost", System.StringComparison.OrdinalIgnoreCase) == 0 ) { // etc. }
11
by: blunt | last post by:
trying to write a program to write the configuration files for a load of wireless access points. i've never been a good programmer and haven't done any for nearly a decade so have obviously made some...
1
by: blunt | last post by:
trying to write a program to write the configuration files for a load of wireless access points. i've never been a good programmer and haven't done any for nearly a decade so have obviously made some...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.