Redigeeri

Jagamisviis:


RuntimeHelpers.Equals(Object, Object) Method

Definition

Determines whether the specified Object instances are considered equal.

public:
 static bool Equals(System::Object ^ o1, System::Object ^ o2);
public static bool Equals (object? o1, object? o2);
public static bool Equals (object o1, object o2);
static member Equals : obj * obj -> bool
Public Shared Function Equals (o1 As Object, o2 As Object) As Boolean

Parameters

o1
Object

The first object to compare.

o2
Object

The second object to compare.

Returns

true if o1 is the same instance as o2, or if both are null, or if both are the same value type and the values of their underlying memory are equal; otherwise, false.

Examples

The following example demonstrates how to compare two objects by using the Equals method.

using System;
using System.Runtime.CompilerServices;

class Program
{

    static void Main(string[] args)
    {

        int x = 1; int y = 1;

        bool ret = RuntimeHelpers.Equals(x, y);

        Console.WriteLine("The return value of RuntimeHelpers.Equals is: " + ret);
    }
}
Imports System.Runtime.CompilerServices


Module Program

    Sub Main(ByVal args() As String)


        Dim x As Integer = 1
        Dim y As Integer = 1

        Dim ret As Boolean
        ret = RuntimeHelpers.Equals(x, y)

        Console.WriteLine("The return value of RuntimeHelpers.Equals is: " + ret)
    End Sub


End Module

Remarks

This method is used by compilers.

Applies to

See also