title: Database Function
body: <p>I want to program a C# Function to handle all database calls which return a <code>list&lt;&gt;</code>. Now since I want this function to handle multiple List Types, I have to be able to pass any List Type in the function (e.g <code>List&lt;Student&gt;</code>, <code>List&lt;Teacher&gt;</code>). I just found out one solution approach which is not quite the way i'd liked since i cannot return a value with my approach:</p>
  
  <pre><code>    private void Execute&lt;T&gt;(string strSql, List&lt;T&gt; list)
      {
          using (OracleConnection conn = new OracleConnection(cnnStr))
          {
              using (OracleCommand objCommand = new OracleCommand(strSql, conn))
              {
                  objCommand.CommandType = CommandType.Text;
                  DataTable dt = new DataTable();
                  OracleDataAdapter adp = new OracleDataAdapter(objCommand);
                  conn.Open();
                  adp.Fill(dt);
                  if (dt != null)
                  {
                      GetListType(list)
                      list = ConvertToList(dt).ToList();
                  }
              }
          }
      }
  </code></pre>
  
  <p>Since my parameter is a <code>List&lt;T&gt;</code> it is not possible to return a value since the function then has to be a void.</p>
  
  <p>Any Suggestion how I could pass any list in the function and also be able to return the list?</p>
  
  <p>Many Thanks in advance</p>