I have had a code snippet comes to modify. In there i found this such syntax.
Session("LightBoxID")?.ToString()
I didn't understand what is that Question mark (?) there means. No googling helped me about any hint
I have had a code snippet comes to modify. In there i found this such syntax.
Session("LightBoxID")?.ToString()
I didn't understand what is that Question mark (?) there means. No googling helped me about any hint
It's the Null-Conditional Operator It's a syntactic sugar for null checking:
return str?.ToString();
will become
if (str == null)
{
return null;
}
return str.ToString();
It performs a null-check on Session("LightBoxID")
before attempting to call .ToString()
on it.