What is the best way to check if only A is null or only B is null? I have been trying many different ways to find something that feels clean, and this is how convoluted it has gotten:
bool CheckForNull(object a, object b)
{
if(a == null && b == null)
{
return false;
}
if(a == null || b == null)
{
return true;
}
return false;
}
My best (and the most obvious) version is:
bool CheckForNull(object a, object b)
{
return a == null && b != null || a != null && b == null;
}
But I don't really like that either. (Sure I could add parenthesis...)
Is there a standard way of doing this that I never learned?