Skip to content

Instantly share code, notes, and snippets.

@guitarrapc
Last active October 24, 2021 08:28
Show Gist options
  • Save guitarrapc/5ad4a1611f465d3c7ccc674a24be23d1 to your computer and use it in GitHub Desktop.
Save guitarrapc/5ad4a1611f465d3c7ccc674a24be23d1 to your computer and use it in GitHub Desktop.
string? x = null;
IsNullOrEmpty(x).Dump();
NullableLength(x).Dump();
PropLength(x).Dump();
TypeOrEmpty(x).Dump();
TypeAndEmpty(x).Dump();
bool IsNullOrEmpty(string? x) => string.IsNullOrEmpty(x);
bool NullableLength(string? x) => x?.Length == 0 || x is null;
bool PropLength(string? x) => x is not {Length: > 0};
bool TypeOrEmpty(string? x) => x is null or "";
bool TypeAndEmpty(string? x) => x is string and "" or null;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment