title: Avoiding a NullReferenceException in an if statement?
body: <p>I'm relatively new to programming in general, and I'm learning C# and using it in Unity3D for game development, and I have a question about if possible, how to avoid NullReferenceExceptions in an if statement when asking if a variable is equal to something when the variable is null.</p>
  
  <p>I have this if statement that checks if the gameObject that a raycast hit is equal to a certain name, and if you are to press out into the void of the skybox that object will of course return null, and this causes a NullReferenceException.</p>
  
  <p>I just want to know, is it even worth trying to avoid even though it doesn't affect anything at all, it's just a bit disturbing to me, XD.</p>
  
  <p>This is the if statement, </p>
  
  <pre><code>if (Input.GetButtonDown ("Fire1") &amp;&amp; rayhit.transform.name == "Reflector") 
          {
  
          }
  </code></pre>