开发者

Any know the reason xmlReader/xmlWriter only provide Create method rather than constructors

Just interesting to know. Why the constructors are protected for those class开发者_如何学Ces.


Because XmlReader/XmlWriter are abstract classes and it doesn't make much sense to have a public constructor in an abstract class. This is a common factory pattern. You use the static Create method which will return a proper implementation based on the argument types in a way that is completely transparent to the developer.


There are specialized types of XMLReader classes like Dictionary Readers, TextReaders etc. that derive from the abstract XMLReader class. You can instantiate those.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜