English 中文(简体)
C# 继承自封的阶级
原标题:C# inherit from nested class within itself

某类人是否可以继承一个被nes的类别,或者在C#实施一个被nes的接口?

class Outer : Outer.Inner {
    class Inner { ... }
    ...
}
最佳回答

如你写的话,没有(见,即。 但是,如果你的内部接口是另一类,那么你可以这样做。

public class SomeClass : SomeOtherClass.ISomeInterface {
    public void DoSomething() {}
}

public class SomeOtherClass {
    public interface ISomeInterface {
        void DoSomething(); 
    }
}
问题回答

只要封套在您的体内可见,而不是<条码>,那么是。

<><>><>>>> 不要将这一职位作为对您是否担任任何评注。 我只说允许这样做。

<><>Edit>: 您不能来自内部的一类,但can > /em> 采用一个称为基类的界面:

public class Base
{
    public interface ISomething
    {
    }
}

public class Derived : Base, Base.ISomething
{
}




相关问题
Subclass check, is operator or enum check

A couple of friends was discussing the use of inheritance and how to check if a subclass is of a specific type and we decided to post it here on Stack. The debate was about if you should implement a ...

C++ Class Inheritance problem

Hi I have two classes, one called Instruction, one called LDI which inherits from instruction class. class Instruction{ protected: string name; int value; public: Instruction(string ...

Overloading a method in a subclass in C++

Suppose I have some code like this: class Base { public: virtual int Foo(int) = 0; }; class Derived : public Base { public: int Foo(int); virtual double Foo(double) = 0; }; ...

Embedding instead of inheritance in Go

What is your opinion of this design decision? What advantages does it have and what disadvantages? Links: Embedding description

Extending Flex FileReference class to contain another property

I want to extend the FileReference class of Flex to contain a custom property. I want to do this because AS3 doesn t let me pass arguments to functions through event listeners, which makes me feel sad,...

Interface Inheritance in C++

I have the following class structure: class InterfaceA { virtual void methodA =0; } class ClassA : public InterfaceA { void methodA(); } class InterfaceB : public InterfaceA { virtual ...