您可以抛出NotImplementedException您不想实现NotSupportedException的方法或无法实现的方法.
最好不要这样做,但是在.NET框架中有些地方会抛出类NotSupportedException,并且设计Stream几乎会迫使你为某些方法抛出这个异常.
从MSDN关于NotSupportedException:
不支持调用的方法时,或者尝试读取,搜索或写入不支持调用的功能的流时引发的异常.
小智 8
是的,如果您使用抽象类,您可以部分实现接口,如下所示:
public interface myinterface
{
void a();
void b();
}
public abstract class myclass : myinterface
{
public void a()
{
///do something
}
public abstract void b(); // keep this abstract and then implement it in child class
}
Run Code Online (Sandbox Code Playgroud)