top of page
  • Foto do escritorFábio Henrique

C# - assigning null value to an anonymous type property

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.194 visualizações0 comentário

Posts recentes

Ver tudo

Comments


bottom of page