1 and 2 conflict, basically.
Either your type is immutable, in which case you can return a reference to the same instance every time... or it's mutable, in which case you have to return a reference to a new object each time.
The reason string.Empty
is fine is precisely because string
is immutable.
Does your type have to be mutable?
EDIT: Based on your comment, it sounds like the properties shouldn't have setters at all. Instead, the values should be passed into the constructor, and stored in readonly fields.
At that point your type is immutable, so you can expose either a public field or property which always returns the same value, i.e.
private static readonly MyType empty = new MyType("", ""); // Or whatever
public static MyType Empty { get { return empty; } }
or
public static readonly MyType Empty = new MyType("", "");
You don't need to worry about anyone setting any properties, because you haven't got any setters...
Jon Skeet
2009-07-31 15:31:01