Skip to content

Instantly share code, notes, and snippets.

@Boztown
Created April 25, 2012 20:39
Show Gist options
  • Save Boztown/2493171 to your computer and use it in GitHub Desktop.
Save Boztown/2493171 to your computer and use it in GitHub Desktop.
C#: NewIfNull
// NewIfNull
public T NewIfNull<T>(T obj) where T:new()
{
if (obj == null) { obj = new T(); }
return obj;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment