Comparing assembly versions in C#

Found a nice little trick to compare version strings in .NET:

Version version1 = new Version("2.4.1");
Version version2 = new Version("2.5");

if (version1 <= version2)
{
// in this case true
}

No need to rely on string.Compare() method !!

Comments

Popular Posts