Created
April 8, 2016 06:26
-
-
Save wallstop/1581ac2e6a368569812533e7cff4b906 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
public class OptionalFieldDAO | |
{ | |
private int? maybeValue_; | |
public OptionalFieldDAO(int? maybeValue) | |
{ | |
maybeValue_ = maybeValue; | |
} | |
public bool Value(out int value) | |
{ | |
if(maybeValue_.HasValue) | |
{ | |
value = maybeValue_.Value; | |
return true; | |
} | |
value = 0; | |
return false; | |
} | |
public static void Main(string[] args) | |
{ | |
OptionalFieldDAO realValue = new OptionalFieldDAO(1); | |
OptionalFieldDAO noValue = new OptionalFieldDAO(null); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment