KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
What are the advantages and when is it appropriate to use a static constructor? public class MyClass { protected MyClass() { } public static MyClass Create() { return new MyClass(); } } and then creating an instance of the class via MyClass myClass = MyClass.Create(); as opposed to just having a public constructor and creating objects using MyClass myClass = new MyClass(); I can see the first approach is useful if the Create method returns an instance of an interface that the class implements...it would force callers create instances of the interface rather than the specific type.
Tags (comma-separated)
Save Edits
Cancel