Factory vs instance constructors

后端 未结 10 1870
渐次进展
渐次进展 2020-12-13 17:41

I can\'t think of any reasons why one is better than the other. Compare these two implementations:

public class MyClass
{
    public MyClass(string fileName         


        
10条回答
  •  独厮守ぢ
    2020-12-13 18:21

    The static Create method can instantiate and return:

    • A MyClass instance
    • An instance of any subclass of MyClass
    • null

提交回复
热议问题