.NET Nested Classes

后端 未结 3 776
粉色の甜心
粉色の甜心 2021-01-24 07:25

The current class library I am working on will have a base class (Field) with over 50 specific \"field\" types which will inherit from \"Field\" and nested for maintain readabil

3条回答
  •  误落风尘
    2021-01-24 08:00

    1. Field has a public nested-class named FieldA
    2. FieldA inherits from Field
    3. thus you can always access FieldA from FieldA.

    The reference isn't creating infinite chains, it is simply pointing to the same class. (some test code)

    When you access FieldA.FieldA, the latter FieldA is accessible due to the fact that the former FieldA is an instance of Field so the latter FieldA actually access Field.FieldA

提交回复
热议问题