title: How to implement the conversion from object to integer and back again to object when creating combinatorial sets
body: <p>I must create combinatorial sets of 3 kinds:  </p>
  
  <ol>
  <li>permutations  </li>
  <li>partial permutations   </li>
  <li>combinations   </li>
  </ol>
  
  <p>It is not a homework. I am on pension and I am trying to keep busy. I learned C# more or less and now I am endeavoring to learn the best practices.   </p>
  
  <p>The process is as follows:<br>
     the input is a list of items (objects) out of which the combinatorial sets must be generated. The kind of objects is not of consequence, as I only use the number of items (<code>list.Count = n</code>).<br>
  I create a list of integers, starting from <code>1</code> and up to <code>n</code>.<br>
  I also create a Dictionary which defines the correspondence between each integer in the list of integers and the corresponding object whose representative the integer is (the key in the dictionary).<br>
  The list of integers is sent as argument to the appropriate method (along with another integer <code>k</code> - the number of items in each partial permutation set or combination, in case of combinations or partial permutations), in order the required kind of combinatorial sets to be created. I already have these methods.
  The output of the method is a list of lists of integers. Each list of integers is a combinatorial set.<br>
  By means of the correspondence dictionary, this list of lists of integers is converted into a list of lists of objects in which each list is a combinatorial set, but now not of integers but of the original items. I do this for each specific method, according to the required type of combinatorial set. 
  I wonder whether there is a more correct way to do this: whatever the kind of combinatorial set, the conversion from object to integer and then back from integer to object must be performed.  </p>
  
  <p>In order to explain, I will use Wyck's example:</p>
  
  <p>Suppose I must generate permutation sets of 3 items (objects): </p>
  
  <p>new List() { objA, objB, objC };
  I create a list of integers: new List() { 1, 2, 3 };</p>
  
  <p>The integer output is: list of permutations: {{1,2,3}, {1,3,2}, {2,1,3}, {2,3,1}, {3,1,2}, {3,2,1}}</p>
  
  <p>I now create the objects output, by using the correspondence dictionary:</p>
  
  <p>1 -> objA</p>
  
  <p>2 -> objB</p>
  
  <p>3 -> objC</p>
  
  <p>so the output is:</p>
  
  <p>new List() { {objA, objB, objC}, {objA, objC, objB}, ..., {objC, objB, objA} };</p>
  
  <p>Now next time I must create combinations of the same 3 objects in sets of 2.
  The same list of 3 integers is passed to another method that creates a list of integer lists, where each list is a combination of 3 integers taken 2 at a time.</p>
  
  <p>The output is: list of combinations: { {1, 2}, {1, 3}, {2, 3} };</p>
  
  <p>And now again I have to convert this list of lists of integers into a list of lists of object:</p>
  
  <p>new List() { {objA, objB}, {objA, objC}, {objB, objC} };</p>
  
  <p>I am not asking for code. Rather, for the way to think and maybe the kind of pattern to use (interface for instance), but also more importantly, how to implement it (not code but explanation, as clear and detailed as possible as of how to get the preliminary step of forming the list of integers and passing it to the correct method and the final step of converting the list of lists of integers into a list of lists of objects in an automated way).
  Thank you in advance.</p>