Hello,
I need to use If condition for null checking while setting value in property during object initiliazation
var asset = select new Asset
{
SerialNumber = dr["Serial Number"].ToString(),
Status = dr["Status"].ToString(),
if (convert.ToString( dr["Date"] )!= null)
Date = DateTime.ParseExact((dr["Date"].ToString()), "dd/MM/yyyy hh:mm:ss", CultureInfo.InvariantCulture);
}
iwants to do something like I highlighted in red. but it does not allow if condition in property setting.
idont want to create object first and then letter set values, because there is some situations.
is ther any way if i can check null.