Let's say we have a situation like this:
// Declare `Nested` struct inside class and interface
class Base {
public struct Nested {}
}
interface IBase {
public struct Nested {}
}
// Inherit them
class ThroughClass: Base {}
class ThroughInterface: IBase {}
// Try reaching `Nested` class through above types
class Test {
ThroughClass.Nested c; // OK
ThroughInterface.Nested i; // Error CS0426: The type name 'Nested' does not exist in the type 'ThroughInterface'
}
Why it's not possible to reach Nested
here using ThroughInterface
? Is this a compiler bug, or design choice (I can't find any documentation related to that)?