I am using the following code to check for a null text-box, and, if it is null, skip the copy to clipboard and move on to the rest of the code.
I don’t understand why I am getting a “Value cannot be NULL” exception. Shouldn’t it see the null and move on without copying to the clipboard?
private void button_Click(object sender, EventArgs e)
{
if (textBox_Results.Text != null) Clipboard.SetText(textBox_Results.Text);
//rest of the code goes here;
}
You should probably be doing your check like this:
Just an extra check so if
textBox_Resultsis evernullyou don’t get a Null Reference Exception.