title: Reflection in C# -- want a list of the data types of a class' fields
body: <p>My C# class MyClass (below) has members a, b, c, d, e, and f.</p>
  
  <p>I'd like to use reflection to obtain a list of the data types of those members;
  for example (borrowing from Python notation):  [ char[], ushort, char, byte, uint, ulong ].</p>
  
  <pre><code>class MyClass
  {
      public  char [ ]    a ;
      public  ushort      b ;
      public  char        c ;
      public  byte        d ;
      public  uint        e ;
      public  ulong       f ;
  }
  
  class MainClass
  {
  public static void Main ( string [] args )
      {
          // get an array (or some kind of list) of MyClass' fields' data types ...
          // for example:  { char[], ushort, char, byte, uint, ulong }
  
          // I've tried the following, but can't get a column of just the data types, alone ...
          MemberInfo[] theMemberInfoArray = typeof(MyClass).GetMembers() ;
          foreach (MemberInfo mi in theMemberInfoArray)
              if (mi.MemberType == MemberTypes.Field)
                      Console.WriteLine ( "&lt;" + mi.MemberType + "&gt;\t"
                      + "&lt;" + mi.GetType() + "&gt;\t"
                      + "&lt;" + mi.Name + "&gt;\t" + mi ) ;
      }
  </code></pre>
  
  <p>}</p>
  
  <p>Program output appears as below:</p>
  
  <pre><code>&lt;Field&gt; &lt;System.Reflection.RtFieldInfo&gt; &lt;a&gt;     Char[]  a
  &lt;Field&gt; &lt;System.Reflection.RtFieldInfo&gt; &lt;b&gt;     UInt16  b
  &lt;Field&gt; &lt;System.Reflection.RtFieldInfo&gt; &lt;c&gt;     Char    c
  &lt;Field&gt; &lt;System.Reflection.RtFieldInfo&gt; &lt;d&gt;     Byte    d
  &lt;Field&gt; &lt;System.Reflection.RtFieldInfo&gt; &lt;e&gt;     UInt32  e
  &lt;Field&gt; &lt;System.Reflection.RtFieldInfo&gt; &lt;f&gt;     UInt64  f
  </code></pre>
  
  <p>I would like program output to appear as:</p>
  
  <pre><code>&lt;Field&gt; &lt;System.Reflection.RtFieldInfo&gt; &lt;a&gt;     &lt;Char[]&gt;     Char[] a
  &lt;Field&gt; &lt;System.Reflection.RtFieldInfo&gt; &lt;b&gt;     &lt;UInt16&gt;     UInt16 b
  &lt;Field&gt; &lt;System.Reflection.RtFieldInfo&gt; &lt;c&gt;     &lt;Char&gt;       Char   c
  &lt;Field&gt; &lt;System.Reflection.RtFieldInfo&gt; &lt;d&gt;     &lt;Byte&gt;       Byte   d
  &lt;Field&gt; &lt;System.Reflection.RtFieldInfo&gt; &lt;e&gt;     &lt;UInt32&gt;     UInt32 e
  &lt;Field&gt; &lt;System.Reflection.RtFieldInfo&gt; &lt;f&gt;     &lt;UInt64&gt;     UInt64 f
  </code></pre>