开发者

Internal property and subclassing

I think it is by design and there is nothing can be done about it, but I found it interesting.

I needed to create a concreate class based on third-party abstract base class. As always, I told Visual Studio to implement abstract base class, which it did, but the code didn't compile compla开发者_如何转开发ining about missing getter. However, event after adding getter manualy, the code still didn't compile. It turned out that this getter is internal. Funny thing about internal property is that it's not shown in metadata (View Definition). Vendor will make it protected in the next release, but at the time being, unless I'm missing some other way, there is nothing I can do about it, right?

-Stan


That's correct.

In fact, we basically do the same thing in Noda Time where we want to expose a type (CalendarSystem) so that clients can pass calendars around - but all the actual interaction is internal to the library, using other internal types. What you've got as a problem in your situation is actually a blessing in ours, as it means we can keep more of the implementation internal and hidden :)

It's harder to do the same thing with interfaces...

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜