title: How to handle NullReferenceException in a foreach?
body: <pre><code>foreach (string s in myField.getChilds()) {
      if (s == null)
          //handle null
      else
          //handle normal value 
  }
  </code></pre>
  
  <p>When I run my program i get a NullReferenceException because getChilds may return null. How can I make my program to continue anyway and handle the exception? I can't handle it outside of the foreach, can't explain why because it will take too much time (and I am sure you guys are busy :P). Any ideas?</p>
  
  <p>I already tryed that way:</p>
  
  <pre><code>foreach (string s in myField.getChilds() ?? new ArrayList(1)) {
          if (s == null)
              //handle null
          else
              //handle normal value 
      }
  </code></pre>
  
  <p>But it does not work, program just jump at the end of the foreach but I want it to enter the foreach instead!</p>