title: C# : 'is' keyword and checking for Not
body: <p>This is a silly question, but you can use this code to check if something is a particular type...</p>
  
  <pre><code>if (child is IContainer) { //....
  </code></pre>
  
  <p>Is there a more elegant way to check for the "NOT" instance?</p>
  
  <pre><code>if (!(child is IContainer)) { //A little ugly... silly, yes I know...
  
  //these don't work :)
  if (child !is IContainer) {
  if (child isnt IContainer) { 
  if (child aint IContainer) { 
  if (child isnotafreaking IContainer) { 
  </code></pre>
  
  <p>Yes, yes... silly question....</p>
  
  <p><strong>Because there is some question</strong> on what the code looks like, it's just a simple return at the start of a method.</p>
  
  <pre><code>public void Update(DocumentPart part) {
      part.Update();
      if (!(DocumentPart is IContainer)) { return; }
      foreach(DocumentPart child in ((IContainer)part).Children) {
         //...etc...
  </code></pre>