Skip to content

Instantly share code, notes, and snippets.

@wallstop
Created April 8, 2016 06:26
Show Gist options
  • Save wallstop/1581ac2e6a368569812533e7cff4b906 to your computer and use it in GitHub Desktop.
Save wallstop/1581ac2e6a368569812533e7cff4b906 to your computer and use it in GitHub Desktop.
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