C# IsNullOrEmpty for all objects

IsNullOrEmpty function for all objects

C# IsNullOrEmpty for all objects

    This will test for IsNullOrEmpty for all objects including string and you can specify multiple values including multiple types.  E.g. “”, null, -1 as a prarms based object or array

    public static bool IsNullOrEmpty(object obj, params object[] emptyValues)
    {
        object[] defaultEmptyValues = new object[] { "", null, -1 };
    
        if (emptyValues == null)
        {
            emptyValues = defaultEmptyValues;
        }
        foreach (object emptyValue in emptyValues)
        {
            if (obj == emptyValue) return true;
        }
        return false;
    
    }