title: Getting the value of a tuple using reflection
body: <p>so I'm trying to get a tuple's value using reflection, the only problem is that I get an exception: System.Reflection.TargetInvocationException. I've tried getting its value as one comment suggested here:
  <a href="https://stackoverflow.com/questions/22932387/casting-to-a-tupleobject-object">Casting to a Tuple&lt;object,object&gt;</a>, <code>var itemX = t.GetProperty("ItemX").GetValue(data);</code> If I uses lem.FieldType.GetProperty("Item1").Name , I can get the name back as Item1, Item2 , etc..., am I using it correctly or is there any other way?</p>
  
  <pre><code>FieldInfo[] fields = this.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy);
  FieldInfo[] tuples = fields.Where(field=&gt;typeof(IStructuralEquatable).IsAssignableFrom(field.FieldType) &amp;&amp; typeof(IStructuralComparable).IsAssignableFrom(field.FieldType)).ToArray();
  
  Debug.WriteLine(tuples.Length.ToString()" -&gt;");
  foreach (var elem in tuples)
  {
      Debug.WriteLine(elem.FieldType.GetProperty("Item1").GetValue(this,null).ToString());
  
      PropertyInfo[] info = elem.FieldType.GetProperties();
      Debug.WriteLine(info[0].GetValue(this,null).ToString());
      for(int i=0;i&lt;info.Length;i++)
      {
          Debug.WriteLine(info[i].GetValue(this,null).ToString());
      }
  
  </code></pre>
  
  <p>And my tuple:</p>
  
  <pre><code>protected Tuple&lt;string,int, int, int&gt; testTuple = new Tuple&lt;string, int, int, int&gt;("Test",1,0,1);
  
  </code></pre>