0

What's the difference beetween this:

public class AnexosTrabalhistasFornecedores : BaseEntity<AnexosTrabalhistasFornecedores>
{
    public Fornecedor Fornecedor { get; set; } = new Fornecedor();
}

and this:

public class AnexosTrabalhistasFornecedores : BaseEntity<AnexosTrabalhistasFornecedores>
{
    public Fornecedor Fornecedor { get; set; }

    public AnexosTrabalhistasFornecedores()
    {
        Fornecedor = new Fornecedor();
    }
}

Does them do the same thing?

  • i think the first one was introduced at some point so that you dont need to always write the latter one. – Welcor Jul 08 '20 at 19:41
  • 5
    Does this answer your question? [Initialization of variables: Directly or in the constructor?](https://stackoverflow.com/questions/14083714/initialization-of-variables-directly-or-in-the-constructor) – Welcor Jul 08 '20 at 19:44

0 Answers0