static void Main() { var items = new FirstLastList <string>(); items.Add("zero"); Console.WriteLine("Count: {0}", items.Count); Console.WriteLine("First: {0}", items.First(1).FirstOrDefault()); Console.WriteLine("Last: {0}", items.Last(1).FirstOrDefault()); Console.WriteLine("Min: {0}", items.Min(1).FirstOrDefault()); Console.WriteLine("Max: {0}", items.Max(1).FirstOrDefault()); items.Clear(); items.Add("first"); items.Add("second"); items.Add("third"); items.Add("fourth"); Console.WriteLine("Count: {0}", items.Count); Console.WriteLine("First: {0}", items.First(1).FirstOrDefault()); Console.WriteLine("Last: {0}", items.Last(1).FirstOrDefault()); Console.WriteLine("Min: {0}", items.Min(1).FirstOrDefault()); Console.WriteLine("Max: {0}", items.Max(1).FirstOrDefault()); Console.WriteLine("RemoveAll('first'): {0}", items.RemoveAll("first")); Console.WriteLine("RemoveAll('fourth'): {0}", items.RemoveAll("fourth")); Console.WriteLine("RemoveAll('first'): {0}", items.RemoveAll("first")); Console.WriteLine("Count: {0}", items.Count); Console.WriteLine("First: {0}", items.First(1).FirstOrDefault()); Console.WriteLine("Last: {0}", items.Last(1).FirstOrDefault()); Console.WriteLine("Min: {0}", items.Min(1).FirstOrDefault()); Console.WriteLine("Max: {0}", items.Max(1).FirstOrDefault()); }
private static void Main() { var items = new FirstLastList<string>(); items.Add("zero"); Console.WriteLine("Count: {0}", items.Count); Console.WriteLine("First: {0}", items.First(1).FirstOrDefault()); Console.WriteLine("Last: {0}", items.Last(1).FirstOrDefault()); Console.WriteLine("Min: {0}", items.Min(1).FirstOrDefault()); Console.WriteLine("Max: {0}", items.Max(1).FirstOrDefault()); items.Clear(); items.Add("first"); items.Add("second"); items.Add("third"); items.Add("fourth"); Console.WriteLine("Count: {0}", items.Count); Console.WriteLine("First: {0}", items.First(1).FirstOrDefault()); Console.WriteLine("Last: {0}", items.Last(1).FirstOrDefault()); Console.WriteLine("Min: {0}", items.Min(1).FirstOrDefault()); Console.WriteLine("Max: {0}", items.Max(1).FirstOrDefault()); Console.WriteLine("RemoveAll('first'): {0}", items.RemoveAll("first")); Console.WriteLine("RemoveAll('fourth'): {0}", items.RemoveAll("fourth")); Console.WriteLine("RemoveAll('first'): {0}", items.RemoveAll("first")); Console.WriteLine("Count: {0}", items.Count); Console.WriteLine("First: {0}", items.First(1).FirstOrDefault()); Console.WriteLine("Last: {0}", items.Last(1).FirstOrDefault()); Console.WriteLine("Min: {0}", items.Min(1).FirstOrDefault()); Console.WriteLine("Max: {0}", items.Max(1).FirstOrDefault()); }
public static void Main() { var products = new FirstLastList <Product>(); products.Add(new Product(0.50m, "coffee")); products.Add(new Product(1.20m, "mint drops")); products.Add(new Product(1.20m, "beer")); products.Add(new Product(0.35m, "candy")); products.Add(new Product(1.20m, "cola")); Console.WriteLine("========================= Count"); Console.WriteLine(products.Count); Console.WriteLine(string.Join(Environment.NewLine, products.First(products.Count))); Console.WriteLine("========================= First"); Console.WriteLine(string.Join(Environment.NewLine, products.First(count))); Console.WriteLine("========================= Last"); Console.WriteLine(string.Join(Environment.NewLine, products.Last(count))); Console.WriteLine("========================= Min"); Console.WriteLine(string.Join(Environment.NewLine, products.Min(count))); Console.WriteLine("========================= Max"); Console.WriteLine(string.Join(Environment.NewLine, products.Max(count))); Console.WriteLine("========================= Remove All @ Price 1.20"); var product = new Product(1.20m); Console.WriteLine($"Removed {products.RemoveAll(product)}"); Console.WriteLine(string.Join(Environment.NewLine, products.First(products.Count))); Console.WriteLine("========================= Clear"); products.Clear(); Console.WriteLine(products.Count); }
static void Main(string[] args) { var items = new FirstLastList <int>(); items.Add(5); items.Add(10); items.Add(-2); // Act items.Last(2).ToList().ForEach(x => Console.Write(x + " ")); }