fork download
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. public class MyCustomObject
  6. {
  7. public int NodeColor { get; set; }
  8. }
  9.  
  10. public class Test
  11. {
  12. public static void Main()
  13. {
  14. List<MyCustomObject> Data = new List<MyCustomObject>()
  15. {
  16. new MyCustomObject(),
  17. new MyCustomObject(),
  18. new MyCustomObject(),
  19. new MyCustomObject(),
  20. new MyCustomObject(),
  21. };
  22.  
  23. int top3 = 3;
  24. Data.Take(top3).ToList().ForEach(gb => gb.NodeColor = 2);
  25. Data.Skip(top3).ToList().ForEach(gb => gb.NodeColor = 3);
  26.  
  27.  
  28. foreach (var myCustomObject in Data)
  29. {
  30. Console.WriteLine(myCustomObject.NodeColor);
  31. }
  32. }
  33. }
Success #stdin #stdout 0.03s 33968KB
stdin
Standard input is empty
stdout
2
2
2
3
3