Lets say I have
if (textbox.Text != null && textbox.Text.Length > someNum)
{
//some code
}
If textbox.Text is null, will it crash because null.Length doesn’t work or will it break after the first expression because the operator is && and there’s no point continuing?
This is called “short-circuit evaluation,” and C# has it. So yes, if
textbox.Textis null, it will not evaluate the second part of the expression.See http://msdn.microsoft.com/en-us/library/2a723cdk(v=VS.71).aspx for specifics.