title: C# switch with types
body: <p>EDIT: <a href="https://stackoverflow.com/a/44012167/4607317">This is now available in C# 7.0.</a></p>
  
  <hr>
  
  <p>I have the following piece of code that checks a given <code>PropertyInfo</code>'s <code>type</code>.</p>
  
  <pre><code>PropertyInfo prop;
  
  // init prop, etc...
  
  if (typeof(String).IsAssignableFrom(prop.PropertyType)) {
      // ...
  }
  else if (typeof(Int32).IsAssignableFrom(prop.PropertyType)) {
      // ...
  }
  else if (typeof(DateTime).IsAssignableFrom(prop.PropertyType)) {
      // ...
  }
  </code></pre>
  
  <p>Is there a way to use a <code>switch</code> statement in this scenario? This is my current solution:</p>
  
  <pre><code>switch (prop.PropertyType.ToString()) {
      case "System.String":
          // ...
          break;
      case "System.Int32":
          // ...
          break;
      case "System.DateTime":
          // ...
          break;
      default:
          // ...
          break;
  }
  </code></pre>
  
  <p>I don't think this is the best solution, because now I have to give the fully qualified <code>String</code> value of the given <code>type</code>. Any tips?</p>