Created
September 6, 2015 10:03
-
-
Save angelovstanton/1c8eb69c230683ea6d7f to your computer and use it in GitHub Desktop.
This file contains 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
float? yourSingle = -1.0f; | |
Console.WriteLine(yourSingle.GetValueOrDefault()); | |
yourSingle = null; | |
Console.WriteLine(yourSingle.GetValueOrDefault()); | |
// assign different default value | |
Console.WriteLine(yourSingle.GetValueOrDefault(-2.4f)); | |
// returns the same result as the above statement | |
Console.WriteLine(yourSingle ?? -2.4f); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment