Skip to content

Instantly share code, notes, and snippets.

@twofingerrightclick
Created September 8, 2021 23:24
Show Gist options
  • Save twofingerrightclick/022ae361bfe1c7525c25cb755f37b118 to your computer and use it in GitHub Desktop.
Save twofingerrightclick/022ae361bfe1c7525c25cb755f37b118 to your computer and use it in GitHub Desktop.
Listing 12.4: Declaring Versions of Various Value Types That Store null
struct NullableInt
{
/// <summary>
/// Provides the value when HasValue returns true
/// </summary>
public int Value{ get; private set; }
/// <summary>
/// Indicates whether there is a value or whether
/// the value is "null"
/// </summary>
public bool HasValue{ get; private set; }
// ...
}
struct NullableGuid
{
/// <summary>
/// Provides the value when HasValue returns true
/// </summary>
public Guid Value{ get; private set; }
/// <summary>
/// Indicates whether there is a value or whether
/// the value is "null"
/// </summary>
public bool HasValue{ get; private set; }
...
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment