Skip to content

Instantly share code, notes, and snippets.

@tompazourek
Created March 14, 2020 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tompazourek/7a4c60d46eab4cdfdcf3483a312c3d9a to your computer and use it in GitHub Desktop.
Save tompazourek/7a4c60d46eab4cdfdcf3483a312c3d9a to your computer and use it in GitHub Desktop.
public static class NullableExtension
{
public static bool TryGetValue<T>(this T? nullableValue, out T value) where T : struct
{
if (!nullableValue.HasValue)
{
value = default;
return false;
}
value = nullableValue.Value;
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment