I'm trying to check if GroupEmails is null before executing this section of my code. However, whenever I am checking for the null value, it returns an error Cannot resolve symbol GroupEmails Is there a better solution for this?
Code
Group = new DB.Group
{
GroupPhones = groupPhones,
GroupEmails = new List<DB.GroupEmail>
{
new DB.GroupEmail
{
Email = groupt.Email
}
}
}
Trying to check if null like the following:
Group = new DB.Group
{
GroupPhones = groupPhones,
GroupEmails == null ? null : new List<DB.GroupEmail>
{
new DB.GroupEmail
{
Email = groupt.Email
}
}
}
Modified Solution Thanks to @Habib
Group = new DB.Group
{
GroupPhones = groupPhones,
GroupEmails = group.Email == null ? null : new List<DB.GroupEmail>
{
new DB.GroupEmail
{
Email = groupt.Email
}
}
}
grouptis null or not?