Skip to content

Instantly share code, notes, and snippets.

@mirmostafa
Created July 30, 2022 08:26
Show Gist options
  • Save mirmostafa/c78a8bd7ffeddef57c5eabcd85e5414b to your computer and use it in GitHub Desktop.
Save mirmostafa/c78a8bd7ffeddef57c5eabcd85e5414b to your computer and use it in GitHub Desktop.
IsNullOrEmpty, using pattern matching
public static bool IsNullOrEmpty([NotNullWhen(false)] this string? str) => str?.Length is null or 0;
public static bool IsNullOrEmpty([NotNullWhen(false)] this string? str) => str is null or { Length: 0 };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment