Hello Vi,
Interface only describes behaviour and serves the purpose of describing
a contractual obligation for classes implementing the interface that
certain behaviour is implemented.
The .net framework is not capable of downcasting objects to their
interfaces. If for example object A implements interface I1 and I2 the
framework will not be able to intelligently downcast the object to I1 or
I2. whereas if an abstract class is used there is no issue as there is
no multiple inheritence.
Hope that makes more sense than its confusing
Thanks
TruongLapVi wrote:
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 {
...........
}
--
Regards,
Dilip Krishnan
MCAD, MCSD.net
dilipdotnet at apdiya dot com