Can we interrupt creating an object in constructor

前端 未结 7 1504
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-31 03:46

Could you help me please. I have one idea but don\'t know how can I implement it.

So the question is: Can we interrupt creating an object in constructor i.e.

7条回答
  •  耶瑟儿~
    2020-12-31 04:30

    That would be possible. Another way would be to put your checking in before you create the object. Like so

    SomeClass someClass = null;
    
    if (someCriteria == VALID)
    {
        someClass = new SomeClass(someCriteria);
    }
    

    Hope this helps.

提交回复
热议问题