Creating .Empty properties

When creating type classes it can be useful to have an .Empty property so you know if an item has been populated. Its quite easy to achieve. All we do is create an instance of the class as a static property. Then we compare our instance to this one when we need to check.

private static readonly YourType _Empty = new YourType();
public static YourType Empty { get { return _Empty; } }

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.