title: The type arguments for methods cannot be inferred from the usage. Try specifying the type arguments explicitly
body: <p>I am trying to populate Autocomplete text from SQL Server in textbox using TextChanged() event. <code>[WindowsForm, C#]</code></p>
  
  <p>I have a partial class Form</p>
  
  <p><strong>TextChanged Event:</strong></p>
  
  <pre><code>private void textBoxFilterCName_TextChanged(object sender, EventArgs e)
      {
          DataTable dt = FillCustomerName(textBoxFilterCName.Text);
          List&lt;string&gt; listNames = CustomerName.ConvertDataTableToList(dt);
          textBoxFilterCName.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
          AutoCompleteStringCollection dataName = new AutoCompleteStringCollection();
          dataName.AddRange(listNames.ToArray());
          textBoxFilterCName.AutoCompleteCustomSource = dataName;
          textBoxFilterCName.AutoCompleteSource = AutoCompleteSource.CustomSource;
      }
  </code></pre>
  
  <p>I am getting this error when I call this method <code>CustomerName.ConvertDataTableToList()</code>.</p>
  
  <blockquote>
    <p><strong>The type arguments for methods 'CustomerName.ConvertDataTableToList(DataTable)' cannot be inferred from the usage. Try specifying the type arguments explicitly.</strong></p>
  </blockquote>
  
  <p><strong>FillCustomerName() Method</strong></p>
  
  <pre><code>public DataTable FillCustomerName(string cName)
      {
          DataTable dtName = new DataTable();
          List&lt;string&gt; listName = new List&lt;string&gt;();
          try
          {
              dbconnection.Open();
              string query = "SELECT [Name] FROM Customers WHERE Is_Active=1 AND Name like @CName + '%'";
              using (SqlCommand cmd = new SqlCommand(query, dbconnection))
              {
                  cmd.Parameters.Add("CName", SqlDbType.VarChar).Value = cName;
                  dtName.Load(cmd.ExecuteReader());
              }
          }
          catch (Exception ex)
          {
              MessageBox.Show(ex.Message, "Connection Error");
          }
          finally
          {
              dbconnection.Close();
          }
          return dtName;
      }
  </code></pre>
  
  <p><strong>CustomerName Class:</strong></p>
  
  <pre><code>public static class CustomerName
  {
      private static T CreateItemFromRow&lt;T&gt;(DataRow row, IList&lt;PropertyInfo&gt; properties) where T : new()
      {
          T item = new T();
          foreach (var property in properties)
          {
              if (property.PropertyType == typeof(System.DayOfWeek))
              {
                  DayOfWeek day = (DayOfWeek)Enum.Parse(typeof(DayOfWeek), row[property.Name].ToString());
                  property.SetValue(item, day, null);
              }
              else
              {
                  property.SetValue(item, row[property.Name], null);
              }
          }
          return item;
      }
      public static List&lt;T&gt; ConvertDataTableToList&lt;T&gt;(this DataTable table) where T : new()
      {
          IList&lt;PropertyInfo&gt; properties = typeof(T).GetProperties().ToList();
          List&lt;T&gt; result = new List&lt;T&gt;();
  
          foreach (var row in table.Rows)
          {
              var item = CreateItemFromRow&lt;T&gt;((DataRow)row, properties);
              result.Add(item);
          }
          return result;            
      }
  }
  </code></pre>
  
  <p>The query is executed and results are generated successfully when I debug the application. But I could not load the datatable results as list. </p>
  
  <p>Possible suggestions for this conversion are most welcome.</p>