开发者

Abstract Class inside an Interface?

开发者 https://www.devze.com 2023-04-03 20:02 出处:网络
I\'m going to have several classes that will inherit from a base abstract class. I\'d like to make sure each of the subclasses has a certain nested class whose actual fields are up to the developer.

I'm going to have several classes that will inherit from a base abstract class.

I'd like to make sure each of the subclasses has a certain nested class whose actual fields are up to the developer.

Nesting an abstract class inside the base abs. class doesn't seem to do the trick because during actual coding, both the nested abs. class and the nested class in the subclass both are available (show up in intellisense).

Having the base class implement an interface that includes a class doesn't work since interfaces only refer to methods that can be implemented, not classes (meaning implementing the interface requires implements methods, but says nothing about classes in the interface.

Any ideas?

Clarifications from the comments:

I have three tables that have about 50 fields in common. They each also have a set of unique fields.

I want to have one class for each (because they do have different biz functio开发者_如何学JAVAns) but want to have some shared methods relating to the common fields.

So those methods go in the base abs class. I also want a single nested class in the base class for the common fields. For the unique fields though, I want to make sure whoever codes the subclass includes a nested class for the unique fields, hence the need for a nested abs class or whatever

It's the unique fields I want developers to group together into a nested class. So we have two sets of nested classes: "CommonData" and "UniqueData". The number is around 190 common fields and up to 10 unique, so I'm trying to establish some groupings to make things easier to work with.


Just add a property to the base class (or interface) that is of the nested class's type


Having the base class implement an interface that includes a class doesn't work since interfaces only refer to methods that can be implemented, not classes (meaning implementing the interface requires implements methods, but says nothing about classes in the interface.

VB.Net can have classes declared inside interfaces, C# can't.

Public Interface Foo

    MustInherit Class Bar

    End Class

End Interface

It might be a bit too exotic though - it would confuse the heck out of me if I found it in some code.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号