fork download
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. var stringList = new List<string> { "1", "2" };
  9. stringList.Shuffle();
  10. foreach (var l in stringList) Console.WriteLine(l);
  11.  
  12. var intList = new List<int> { 1, 2 };
  13. intList.Shuffle();
  14. foreach (var l in intList) Console.WriteLine(l);
  15. }
  16. }
  17.  
  18. public static class ListExtensions
  19. {
  20. public static void Shuffle<T>(this List<T> list)
  21. {
  22. Console.WriteLine(typeof(T));
  23. var t = list[0];
  24. list[0] = list[1];
  25. list[1] = t;
  26. }
  27. }
Success #stdin #stdout 0.02s 16008KB
stdin
Standard input is empty
stdout
System.String
2
1
System.Int32
2
1