fork download
  1. using System;
  2. using System.Globalization;
  3. using System.Linq;
  4. using System.Collections.Generic;
  5. using System.Diagnostics;
  6.  
  7. public class Test
  8. {
  9.  
  10.  
  11. public static void Main()
  12. {
  13. var myList = new List<string>() { "A", "B", "C", "D", "E", "F" };
  14. var indices = new[] { 7, 1, 3, 0, 10 };
  15. var result = myList.Select((Item, Index) => new { Item, Index })
  16. .Join(indices, item => item.Index, index => index, (item, index) => item);
  17.  
  18. foreach (var obj in result)
  19. Console.WriteLine(obj);
  20. }
  21. }
Success #stdin #stdout 0.06s 35136KB
stdin
Standard input is empty
stdout
{ Item = A, Index = 0 }
{ Item = B, Index = 1 }
{ Item = D, Index = 3 }