System.Version.Equals Method

Returns a value indicating whether the current Version object is equal to a specified object.

Syntax

public override bool Equals (object obj)

Parameters

obj
An object to compare with the current Version object, or null.
obj
An object to compare with the current Version object, or null.

Returns

true if the current Version object and obj are both Version objects, and every component of the current Version object matches the corresponding component of obj; otherwise, false.

Remarks

Note: This method overrides object.Equals(object).

Example

C# Example

using System;
class VersionEqualsExample {
   static void testEquals(Version v1, Version v2) {
      Console.Write("It is {0} that version ",
                    v1.Equals(v2));
      Console.WriteLine("{0} is equal to {1}.",
                    v1, v2);
   }
   public static void Main() {
      Version vers1 = new Version( "6.1.2.4" );
      Version vers2 = new Version( 6, 1 );
      testEquals( vers1, vers1 );
      testEquals( vers1, vers2 );
   }
}
   

The output is

It is True that version 6.1.2.4 is equal to 6.1.2.4.
It is False that version 6.1.2.4 is equal to 6.1.

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0