title: How to Define that a Type T must have a field "ID"
body: <p>This sample:</p>
  
  <pre><code>public static void createDictionary&lt;T&gt;(IEnumerable&lt;T&gt; myRecords)
              where T: T.ID // Wont Compile
          {
              IDictionary&lt;int, T&gt; dicionario = myRecords.ToDictionary(r =&gt; r.ID);
  
  
              foreach (var item in dicionario)
              {
                  Console.WriteLine("Key = {0}",item.Key);
  
                  Type thisType = item.Value.GetType();
  
                  StringBuilder sb = new StringBuilder();
  
                  foreach (var itemField in thisType.GetProperties())
                  {
                      sb.AppendLine(string.Format("{0} = {1}", itemField.Name, itemField.GetValue(item.Value, null)));
                  }
  
                  Console.WriteLine(sb);
              }
  
          }
  </code></pre>
  
  <p>how can I force the type passed as parameter has a field called "ID"?</p>