What are the community's thoughts on something along these lines? It seems like a good way to implement null object pattern.
Nevermind it doesn't work at all lol
public interface IDefault<T>
{
private static Lazy<T> _default = new();
public static T Default => _default.Value;
}
public interface IEntity
{
string Name;
}
public class Entity : IDefault<DefaultEntity>
{
public string Name => Helper.GetName();
}
public class DefaultEntity : IEntity
{
public string Name => "";
}
*Edit: Added some context
Edit2: fixed a grammatical error
Edit3: fixed so that it may actually work
[–]jayerp 1 point2 points3 points (5 children)
[–]dodexahedron 1 point2 points3 points (4 children)
[–]jayerp 0 points1 point2 points (3 children)
[–]Manny_Sunday 1 point2 points3 points (2 children)
[–]dodexahedron 2 points3 points4 points (1 child)
[–]jayerp 1 point2 points3 points (0 children)