M
Manish Jain
Platform : ASP.Net/C#
void SomeFunction(DateTime date)
{
string text = date.ToString(); //This crashes if date is null
}
I am using a construct similar to above. I want to check if the date is null
or nor before processing it, but I am not able to figure out the syntax.
Please suggest my approach.
I want something like:
if (date is null)
{
text = "";
}
else
{
text = date.ToString();
}
Thanks
Manish
void SomeFunction(DateTime date)
{
string text = date.ToString(); //This crashes if date is null
}
I am using a construct similar to above. I want to check if the date is null
or nor before processing it, but I am not able to figure out the syntax.
Please suggest my approach.
I want something like:
if (date is null)
{
text = "";
}
else
{
text = date.ToString();
}
Thanks
Manish