title: Pass unknown List<T> as parameter?
body: <p>Here Im trying to call a unknown <code>List&lt;T&gt;</code> as a parameter in my createReports method on a button click. When I click <code>button1</code> I need a List from  <code>CustomersInfo</code> class and when <code>button2</code> is clicked I would like a List from  <code>ExpenseInfo</code> class.
  Is this possible?  </p>
  
  <p>Code has been Updated.</p>
  
  <pre><code>class CustomersInfo
      {
          public string Name
          {
              get;
              set;
          }
  
          public string Amount
          {
              get;
              set;
          }
      }
  
  class ExpenseInfo
      {
          public string Category
          {
              get;
              set;
          }
          public string Name
          {
              get;
              set;
          }
  
          public string Amount
          {
              get;
              set;
          }
      }
  
  List&lt;CustomersInfo&gt; customerInfo = new List&lt;CustomersInfo&gt;();
  List&lt;ExpenseInfo&gt; expenseInfo = new List&lt;ExpenseInfo&gt;();
  
  private void button1_Click(object sender,EventArgs e)
      {
          createReports(button1.Text, customerInfo);
      }
  
  private void button2_Click(object sender, EventArgs e)
      {
          createReports(button2.Text, expenseInfo);
      }
  
  viewForm.documentViewer1.CloseDocument();
          string fileName = Application.StartupPath + "\\**\\report.docx";
          if (File.Exists(fileName))
          {
              File.Delete(fileName);
          }
          try
          {
              var application = new Microsoft.Office.Interop.Word.Application();
              var distinct = report.Distinct().GroupBy(x =&gt; x.Name).Select(y =&gt; y.First());
              var document = application.Documents.Add(Template: Application.StartupPath + "/**/Templates/Reports.docx");
              total = 0;
              foreach (Microsoft.Office.Interop.Word.Field field in document.Fields)
              {
                  if (field.Code.Text.Contains("Info"))
                  {
                      field.Select();
                      application.Selection.TypeText(Label);
                  }
                  else if (field.Code.Text.Contains("Grid"))
                  {
                      field.Select();
  
  
  
                      int RowCount = distinct.Count();
                      int ColumnCount = type.GetProperties().Length;
                      Object[,] DataArray = new object[RowCount, ColumnCount + 1];
  
                      //add rows
                      int r = 0;
                      int d = 0;
  
                      foreach (var client in distinct)
                      {
                          clientTotal = 0;
                          foreach (var info in report)
                          {
                              if (client.Name == info.Name)
                              {
                                  clientTotal = Convert.ToDecimal(info.Amount.Remove(0, 1)) + clientTotal;
                              }
                          }
                          total = total + clientTotal;
  
  
                          DataArray[r, 0] = client.Name;
                          DataArray[r++, 1] = clientTotal.ToString("C2");
                      }
  
                      //page orintation
                      document.PageSetup.Orientation = Microsoft.Office.Interop.Word.WdOrientation.wdOrientPortrait;
  
  
                      dynamic oRange = document.Content.Application.Selection.Range;
                      string oTemp = "";
                      for (r = 0; r &lt;= RowCount - 1; r++)
                      {
                          for (int c = 0; c &lt;= ColumnCount - 1; c++)
                          {
                              oTemp = oTemp + DataArray[r, c] + "\t";
  
                          }
                      }
  
                      //table format
                      oRange.Text = oTemp;
  
                      object Separator = Microsoft.Office.Interop.Word.WdTableFieldSeparator.wdSeparateByTabs;
                      object ApplyBorders = true;
                      object AutoFit = true;
                      object AutoFitBehavior = Microsoft.Office.Interop.Word.WdAutoFitBehavior.wdAutoFitFixed;
  
                      oRange.ConvertToTable(ref Separator, ref RowCount, ref ColumnCount,
                                            Type.Missing, Type.Missing, ref ApplyBorders,
                                            Type.Missing, Type.Missing, Type.Missing,
                                            Type.Missing, Type.Missing, Type.Missing,
                                            Type.Missing, ref AutoFit, ref AutoFitBehavior, Type.Missing);
  
                      oRange.Select();
  
                      document.Application.Selection.Tables[1].Select();
                      document.Application.Selection.Tables[1].Rows.AllowBreakAcrossPages = 0;
                      document.Application.Selection.Tables[1].Rows.Alignment = 0;
                      document.Application.Selection.Tables[1].Rows[1].Select();
                      document.Application.Selection.InsertRowsAbove(1);
                      document.Application.Selection.Tables[1].Rows[1].Select();
  
                      //header row style
                      document.Application.Selection.Tables[1].Rows[1].Range.Bold = 1;
                      document.Application.Selection.Tables[1].Rows[1].Range.Font.Name = "Arial";
                      document.Application.Selection.Tables[1].Rows[1].Range.Font.Size = 11;
  
                      //add header row manually
                      document.Application.Selection.Tables[1].Cell(1, 1).Range.Text = "Client";
                      document.Application.Selection.Tables[1].Cell(1, 2).Range.Text = "Amount";
  
                      //table style 
                      document.Application.Selection.Tables[1].set_Style("Grid Table 4 - Accent 1");
                      for (int c = 1; c &lt;= document.Application.Selection.Tables[1].Rows.Count - 1; c++)
                      {
                          document.Application.Selection.Tables[1].Rows[c].Range.Font.Size = 9;
                      }
  
                      document.Application.Selection.Tables[1].Rows[1].Select();
                      document.Application.Selection.Cells.VerticalAlignment = Microsoft.Office.Interop.Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                  }
                  else if (field.Code.Text.Contains("total"))
                  {
                      field.Select();
                      application.Selection.TypeText("Total Income by Client " + total.ToString("C2"));
                  }
              }
  
              document.SaveAs(fileName);
              document.Close();
              application.Quit();
              application = null;
              document = null;
              GC.Collect();
              GC.WaitForPendingFinalizers();
              GC.Collect();
              GC.WaitForPendingFinalizers();
          }
          catch (Exception ex)
          {
              // Get stack trace for the exception with source file information
              var st = new StackTrace(ex, true);
              // Get the top stack frame
              var frame = st.GetFrame(st.FrameCount - 1);
              // Get the line number from the stack frame
              var line = frame.GetFileLineNumber();
              MessageBox.Show(line.ToString());
          }
          showReports(Label);
  </code></pre>
  
  <p>Any help would be greatly appreciated. Thanks in advance.</p>