title: How to dynamically group a list and select values using linq query in C#?
body: <p>I have an input list <strong>test</strong></p>
  
  <pre><code>class Tracker
  {
      public string Toolid {get;set;}
      public string Description {get;set;}
      public int length {get;set;}
      public int breadth {get;set;}
      public int height {get;set;}
  
  }
  
  List&lt;Tracker&gt; test = new List&lt;Tracker&gt;();
  test.Add( new Tracker {Toolid="A.1",Description ="ABC",length = 10, breadth =10,height = 50});
  test.Add( new Tracker {Toolid="A.1",Description ="ABC", length = 10, breadth =10,height = 50});
  test.Add( new Tracker {Toolid="C.1",Description ="ABCD", length = 10, breadth =10,height = 50});
  test.Add( new Tracker {Toolid="D.1",Description ="Admin123", length = 10, breadth =10,height = 50});
  </code></pre>
  
  <p>This list contain more values like weight, colour etc.
  For better understanding I have added only 5 member variables in the class <strong>Tracker</strong>.</p>
  
  <p>I need to Group the list <strong>test</strong> based on the values of another list (<strong>grpList</strong>).
  This list (<strong>grpList</strong> ) is dynamic, hence the number of parameter and values in the list may change. 
  <strong>So I need a dynamic Group By of list using LINQ query.</strong></p>
  
  <p>case 1 : sometimes this list <strong>grpList</strong>  contain 2 values .</p>
  
  <pre><code>List &lt;string&gt; grpList = new List&lt;string&gt;();
  
  grpList.Add(ToolId);
  grpList.Add(Description);
  </code></pre>
  
  <p>if So , I have to group the list <strong>test</strong> with ToolId and Description,</p>
  
  <p>case 2 : if list <strong>grpList</strong>  contain N values , I have to group the list <strong>test</strong> with 'N' values .</p>
  
  <p>The number of values in the <strong>grpList</strong> varies. I have group the main list <strong>test</strong> using the values in grpList. If <strong>grpList</strong> contain 2 values ,group the <strong>test</strong> list with 2 values . if  If <strong>grpList</strong> contain 5 values , group the <strong>test</strong> list with 5 values.</p>
  
  <p>NB : I need to Group the list <strong>test</strong> ( Main list). <br>
       <strong>grpList</strong> values only for grouping .</p>