tags:

views:

412

answers:

2

Hi,

I like to learn difference between XMLReader.Create and new XMLTextReader() to read XML. Why would I choose one over another ? Performance issue ? I know XMLReader is an abstract type for XMLTextReader, at least that is what I read before but I saw some where people suggested using XMLReader.Create() methods rather than new XMLReader() instance.

Thank in advance...

Sincerely.

+7  A: 

XmlReader.Create allows you to specify XmlReaderSettings, which none of the XmlTextReader constructor overloads do.

Jon Skeet
Thanks, it helped me a lot.
Braveyard
+1  A: 

For a general answer to why this sort of code esists at all you might want to take a look at the Factory Method Pattern. Using a factory method and an abstract class/interface helps you to write more general code by not tying yourself to a specific implementation. This can help to make your code more easily able to take advantage of new features or to be used in different situations.

Dolphin
Thanks, I didn't know that.
Braveyard