title: c# 7.0: switch on System.Type
body: <p>No existing question has an answer to this question.</p>
  <p>In c# 7, can I switch directly on a <code>System.Type</code>?</p>
  <p>When I try:</p>
  <pre><code>    switch (Type)
      {
        case typeof(int):
          break;
      }
  </code></pre>
  <p>it tells me that <code>typeof(int)</code> needs to be a constant expression.</p>
  <p>Is there some syntatic sugar that allows me to avoid <code>case nameof(int):</code> and directly compare the types for equality? <code>nameof(T)</code> in a case statement is not completely good because namespaces. So although name collision is probably not be applicable for <code>int</code>, it will be applicable for other comparisons.</p>
  <p>In other words, I'm trying to be more type-safe than this:</p>
  <pre><code>    switch (Type.Name)
      {
        case nameof(Int32):
        case nameof(Decimal):
          this.value = Math.Max(Math.Min(0, Maximum), Minimum); // enforce minimum 
          break;
      }
  </code></pre>