Created
September 8, 2021 23:24
-
-
Save twofingerrightclick/022ae361bfe1c7525c25cb755f37b118 to your computer and use it in GitHub Desktop.
Listing 12.4: Declaring Versions of Various Value Types That Store null
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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