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?

有帮助吗?

解决方案

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top