T
TruongLapVi
Hi,
Why C# does not support Interface static member ?
Some time I want implement NullObject Pattern:
public interface INullObject {
public static INullObject Null {
get { return NullObject.Instance; } // !!! Wrong, C# not support ?
}
}
public class NullObject {
private static instance; // Singleton pattern
private NullObject () {};
static NullObject() { instance = new NullObject; }
public static NullObject Null {
get { instance; )
}
}
}
public class NullObjectImpl : INullObject, FooClass {
...........
}
Why C# does not support Interface static member ?
Some time I want implement NullObject Pattern:
public interface INullObject {
public static INullObject Null {
get { return NullObject.Instance; } // !!! Wrong, C# not support ?
}
}
public class NullObject {
private static instance; // Singleton pattern
private NullObject () {};
static NullObject() { instance = new NullObject; }
public static NullObject Null {
get { instance; )
}
}
}
public class NullObjectImpl : INullObject, FooClass {
...........
}