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

IsFilled(), IsEmpty()

IsFilled and IsEmpty provide a more natural (english language) alternative to check if the value of a string is null, empty or filled

Source

public static class StringExtensions
{
    public static bool IsEmpty(this string s)
    {
        return string.IsNullOrEmpty(s);
    }

    public static bool IsFilled(this string s)
    {
        return !string.IsNullOrEmpty(s);
    }
}

Example

if (name.IsFilled()) {
  // do stuff
}
if (name.IsEmpty()) {
  // do stuff
}

Author: Loek van den Ouweland

Submitted on: 14 nov 2019

Language: csharp

Type: System.String

Views: 3493