Last active
December 17, 2016 15:20
-
-
Save rmnblm/58faebfd49243f27e80115b116134f03 to your computer and use it in GitHub Desktop.
Swift Optionals in C#
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
// int num = null; -> Error | |
int? num = null; | |
if (num.HasValue) | |
{ | |
System.Console.WriteLine("num = " + num.Value); | |
} | |
else | |
{ | |
System.Console.WriteLine("num = Null"); | |
} | |
// Output: "num = Null" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment