How to use switch-case on a Type?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/298976/c-sharp-is-there-a-better-alternative-than-this-to-switch-on-type">C# - Is there a better alternative than this to ‘switch on type’?</a>  </p>
</blockquote>



<p>I need to iterate through all properties of my class and to check if its type of int the i need to do something, if its string .. then do something. I need it using switch-case. Here i am using switch in the following manner, but it asks for some constant. see the code below:</p>

<pre><code> public static bool ValidateProperties(object o)
        {
            if(o !=null)
            {
                var sourceType = o.GetType();
                var properties = sourceType.GetProperties(BindingFlags.Public | BindingFlags.Static);
                foreach (var property in properties)
                {
                    var type = property.GetType();
                    switch (type)
                    {
                        *case typeof(int):* getting error here
                            // d
                    }
                }
            }
        }
</code></pre>

<p>Also i want to know , what check should I use, typeof(int) or typeof(Int32)?</p>
