fork download
  1. public partial class Form1 : Form
  2. {
  3. public Form1()
  4. {
  5. InitializeComponent();
  6.  
  7.  
  8. }
  9.  
  10. public Control AddControl(Control c)
  11. {
  12. this.Controls.Add(c);
  13. return c;
  14. }
  15. public Control CreateControl()
  16. {
  17. return new Control();
  18. }
  19.  
  20. private void button1_Click(object sender, EventArgs e)
  21. {
  22. var list = new List<int>() { 1,2,3,4,5 };
  23.  
  24. var list2 = list.Select((v) => this.CreateControl());
  25. list2.ForEach((v) => this.AddControl(v));
  26. list2.ForEach((v) => Console.WriteLine(v.Parent.Name));
  27. }
  28.  
  29. private void button2_Click(object sender, EventArgs e)
  30. {
  31.  
  32. var list = new List<int>() { 1, 2, 3, 4, 5 };
  33.  
  34. var list2 = list.Select((v) => this.CreateControl());
  35. var list3 = list2.Select((v) => this.AddControl(v));
  36. list3.ForEach((v) => Console.WriteLine(v.Parent.Name));
  37. }
  38.  
  39. }
  40. public static class LinqExtension
  41. {
  42. public static void ForEach<T>(this IEnumerable<T> arr, Action<T> pred)
  43. {
  44. foreach (var v in arr) { pred(v); }
  45. }
  46. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(1,30): error CS0246: The type or namespace name `Form' could not be found. Are you missing a using directive or an assembly reference?
Compilation failed: 1 error(s), 0 warnings
stdout
Standard output is empty