title: Getting object name from list
body: <p>Is there a way to retrieve the name of an object stored in a list?</p>
  
  <p>What I want to do is to add an object name - the name of matrix in this particular case - prior to printing out properties of that matrix.</p>
  
  <pre><code>internal class Program
  {
      private static void Main(string[] args)
      {
          //Create a collection to help iterate later
          List&lt;Matrix&gt; list_matrix = new List&lt;Matrix&gt;();
  
          //Test if all overloads work as they should.
          Matrix mat01 = new Matrix();
          list_matrix.Add(mat01);
  
          Matrix mat02 = new Matrix(3);
          list_matrix.Add(mat02);
  
          Matrix mat03 = new Matrix(2, 3);
          list_matrix.Add(mat03);
  
          Matrix mat04 = new Matrix(new[,] { { 1, 1, 3, }, { 4, 5, 6 } });
          list_matrix.Add(mat04);
  
          //Test if all methods work as they should.     
          foreach (Matrix mat in list_matrix) 
          {
              //Invoking counter of rows &amp; columns
              //HERE IS what I need - instead of XXXX there should be mat01, mat02...
              Console.WriteLine("Matrix XXXX has {0} Rows and {1} Columns", mat.countRows(), mat.countColumns()); 
          }
      }
  }
  </code></pre>
  
  <p>In short I need here</p>
  
  <pre><code>Console.WriteLine("Matrix XXXX has {0} Rows and {1} Columns",
                    mat.countRows(),
                    mat.countColumns());
  </code></pre>
  
  <p>a method to write out name of that particular object - matrix.</p>