How is it that the abstract class XmlWriter can be instantiated using XmlWriter.Create(... ?
Posted
by Cognize
on Stack Overflow
See other posts from Stack Overflow
or by Cognize
Published on 2010-05-21T11:08:27Z
Indexed on
2010/05/21
11:10 UTC
Read the original article
Hit count: 337
Hi,
Just looking to clarify my understanding of the workings of the XmlWriter and abstract classes in general.
My thinking is (was) that an abstract class can not be instantiated, although it can contain base methods that can be used by an inheriting class.
So, while investigating XmlWriter, I find that to instantiate the XmlWriter, you call XmlWriter.Create(.... , which returns an instance of... XmlWriter, which can then be used:
FileStream fs = new FileStream("XML.xml", FileMode.Create);
XmlWriter w = XmlWriter.Create(fs);
XmlSerializer xmlSlr = new XmlSerializer(typeof(TestClass));
xmlSlr.Serialize(fs, tsIn);
This clearly works, as tested. Can anyone help me understand what is going on here. As far as I can see there is or should be no 'instance' to work with here??
© Stack Overflow or respective owner