title: What is quicker, switch on string or elseif on type?
body: <p>Lets say I have the option of identifying a code path to take on the basis of a string comparison or else iffing the type:</p>
  
  <p>Which is quicker and why?</p>
  
  <pre><code>switch(childNode.Name)
  {
      case "Bob":
        break;
      case "Jill":
        break;
      case "Marko":
        break;
  }
  
  if(childNode is Bob)
  {
  }
  elseif(childNode is Jill)
  {
  }
  else if(childNode is Marko)
  {
  }
  </code></pre>
  
  <p><strong>Update:</strong> The main reason I ask this is because the switch statement is perculiar about what counts as a case. For example it wont allow you to use variables, only constants which get moved to the main assembly. I assumed it had this restriction due to some funky stuff it was doing. If it is only translating to elseifs (as one poster commented) then why are we not allowed variables in case statements?</p>
  
  <p><strong>Caveat:</strong> I am post-optimising. This method is called <em>many</em> times in a slow part of the app.</p>