Equality Operator

Decimal.Equality Operator (Decimal, Decimal)


Returns a value that indicates whether two Decimal values are equal.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

public static bool operator ==(
	decimal d1,
	decimal d2


Type: System.Decimal

The first value to compare.

Type: System.Decimal

The second value to compare.

Return Value

Type: System.Boolean

true if d1 and d2 are equal; otherwise, false.

The Equality method defines the operation of the equality operator for Decimal values. It enables code such as the following:

using System;
using System.Management;
public class RemoteConnect 
    public static void Main() 
        /*// Build an options object for the remote connection
        //   if you plan to connect to the remote
        //   computer with a different user name
        //   and password than the one you are currently using

             ConnectionOptions options = 
                 new ConnectionOptions();

             // and then set the options.Username and 
             // options.Password properties to the correct values
             // and also set 
             // options.Authority = "ntlmdomain:DOMAIN";
             // and replace DOMAIN with the remote computer's
             // domain.  You can also use Kerberos instead
             // of ntlmdomain.

        // Make a connection to a remote computer.
        // Replace the "FullComputerName" section of the
        // string "\\\\FullComputerName\\root\\cimv2" with
        // the full computer name or IP address of the
        // remote computer.
        ManagementScope scope = 
            new ManagementScope(

        // Use this code if you are connecting with a 
        // different user name and password:
        // ManagementScope scope = 
        //    new ManagementScope(
        //        "\\\\FullComputerName\\root\\cimv2", options);
        // scope.Connect();

        //Query system for Operating System information
        ObjectQuery query = new ObjectQuery(
            "SELECT * FROM Win32_OperatingSystem");
        ManagementObjectSearcher searcher = 
            new ManagementObjectSearcher(scope,query);

        ManagementObjectCollection queryCollection = searcher.Get();
        foreach ( ManagementObject m in queryCollection)
            // Display the remote computer information
            Console.WriteLine("Computer Name : {0}", 
            Console.WriteLine("Windows Directory : {0}", 
            Console.WriteLine("Operating System: {0}",  
            Console.WriteLine("Version: {0}", m["Version"]);
            Console.WriteLine("Manufacturer : {0}", 

If the language you're using doesn't support custom operators, call the Equals method instead.

Universal Windows Platform
Available since 4.5
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
© 2015 Microsoft