Skip to content

Instantly share code, notes, and snippets.

@savaged
Created April 20, 2022 07:30
Show Gist options
  • Select an option

  • Save savaged/4612cafbfa651d80020adf6d658b0cda to your computer and use it in GitHub Desktop.

Select an option

Save savaged/4612cafbfa651d80020adf6d658b0cda to your computer and use it in GitHub Desktop.
Empty Model object to avoid null reference issues
public class EmptyThingModel : BaseModel
{
private static readonly ThingModel _default = new EmptyThingModel();
static EmptyThingModel() { }
private EmptyThingModel() { }
public static ThingModel Default => _default;
public new int Id => -1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment