与我之前合作过的一个团队,每当创建一个新的服务类来处理数据层和表示层之间的业务逻辑时,都会执行如下操作:classDocumentService{publicDocumentRepositoryDocumentRepository{get;set;}publicDocumentService(){if(DocumentRepository==null)DocumentRepository=newDocumentRepository();}}我一直不太明白为什么要对null进行检查。如果正在调用构造函数,则意味着它必须为null..因为它是一个新实例,对吗?为什么要这样做?在我看来,这是