static void Main(string[] args) { ModifyNode <int> list = new ModifyNode <int>(); list.Add(7); list.Add(5); list.Add(-1); list.Add(3); list.ForEach(d => Console.WriteLine(d)); int maxNum = int.MinValue; int minNum = int.MaxValue; long sum = 0; list.ForEach(d => { if (d >= maxNum) { maxNum = d; } if (d <= minNum) { minNum = d; } sum += d; }); Console.WriteLine("Max:" + maxNum + "____Min:" + minNum + "____Sum:" + sum); }
static void Main(string[] args) { ModifyNode <int> list = new ModifyNode <int>(); for (int i = 1; i <= 10; i++) { list.Add(i); } int max = list.first.Data; int min = list.first.Data; int sum = 0; list.ForEach((x) => { Console.WriteLine(x); max = Math.Max(max, x); min = Math.Min(min, x); sum += x; }); Console.WriteLine("Max:" + max + "*****Min:" + min + "*****Sum:" + sum); }