top of page

C# - assigning null value to an anonymous type property

Foto do escritor: Fábio HenriqueFábio Henrique

To assign a null value to an anonymous type property you have to cast the null value to the right type so that the compiler knows which type you want for that property.



var employee = new
{
    Name = "Fabio Henrique",
    Salary = (int?)null,
    HasEmail = (bool?)null,
};



2.292 visualizações0 comentário

Posts recentes

Ver tudo

Comments


bottom of page