Question

Might seems silly question and can learn from google but I am new to C# and trying to figure out possible future clarifications. So here is best places to ask.

For example: Why do not we write;

XmlWriter writer = new XmlWriter("C:\\1.xml",settings);

instead writing;

XmlWriter writer = XmlWriter.Create("C:\\1.xml",settings);

(No new keyword and .Create method.)

What is XmlWriter fully named as a class?

Also how do I know in BCL which class to instantiate how? Like how do I know its syntax if I do not know. What is the ieasy way? How can intelligence help me?

Was it helpful?

Solution

Because this is a factory method, it creates one of the derived classes like XmlWellFormedWriter, XmlAsyncCheckWriter, etc. which depend on settings.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top