ExtensionMethod.NET Home of 877 C#, Visual Basic, F# and Javascript extension methods


Determines whether two String objects have the same value. Null and String.Empty are considered equal values.


public static bool EqualsByValue(this string inString, string compared)
    if (string.IsNullOrEmpty(inString) && string.IsNullOrEmpty(compared))
        return true;

    // If we get here, then "compared" necessarily contains data and therefore, strings are not equal.
    if (inString == null)
        return false;

    // Turn down to standard equality check.
    return inString.Equals(compared);


bool areEqual = a.EqualsByValue(b);

Author: Omniscient Technology Inc

Submitted on: 5 okt. 2009

Language: C#

Type: System.String

Views: 4043