Version Checking with System.Version

The .Net Framework makes version checking extremely simple. The framework provides a Version class that implements IComparable. Comparing two versions is as easy as the code below:

using System;

namespace VersionChecker {
    class Program {
        static void Main(string[] args) {
            Version v1 = new Version("");
            Version v2 = new Version("");

            if (v1 > v2) {
                Console.WriteLine("v1 is higher");
            } else {
                Console.WriteLine("v2 is higher");


Here’s the result:


Leave a Reply