Object - ReferenceEquals

Determines whether the specified instances are the same instance.

Try it

public static void Main()
{
    string  thisNull = null;

    // C# Extension Method: Object - ReferenceEquals
    bool result1 = thisNull.ReferenceEquals(null); // return true;
    bool result2 = thisNull.ReferenceEquals(""); // return false;

    Console.WriteLine(result1);
    Console.WriteLine(result2);
}

View Source
using System;

public static partial class Extensions
{
    /// <summary>
    ///     Determines whether the specified  instances are the same instance.
    /// </summary>
    /// <param name="objA">The first object to compare.</param>
    /// <param name="objB">The second object  to compare.</param>
    /// <returns>true if  is the same instance as  or if both are null; otherwise, false.</returns>
    public static Boolean ReferenceEquals(this Object objA, Object objB)
    {
        return Object.ReferenceEquals(objA, objB);
    }
}