Skip to content

Instantly share code, notes, and snippets.

@isidore
Last active July 30, 2016 20:28
Show Gist options
  • Save isidore/f55c5455a2de28e483fef7f09b881dde to your computer and use it in GitHub Desktop.
Save isidore/f55c5455a2de28e483fef7f09b881dde to your computer and use it in GitHub Desktop.
string result = null;
result = result.DoIfNull(Win);
result = result.DoIfNull(Advantage);
result = result.DoIfNull(ScoreNormal);
result = result.DoIfNull(ScorePerson1);
result = result.DoIfNull(ScorePerson2);
result = result.DoIfNull(ScoreTie);
return result;
public static T DoIfNull<T>(this T t, Func<T> f )
{
if (t == null)
{
return f();
}
return t;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment