public static void Main(string[] args) { var testSections = new CustomSections(); testSections.Add(new Section { Price = 100, Name = "Volleyball" }); testSections.Add(new Section { Price = -100, Name = "Football" }); testSections.Add(new Section { Price = 10, Name = "Ragby" }); testSections.ForEach(Console.WriteLine); Console.WriteLine("========================"); var sections = new CustomCollectionFromZero <Section>(); sections.Add(new Section { Price = 100, Name = "Volleyball" }); sections.Add(new Section { Price = -100, Name = "Football" }); sections.Add(new Section { Price = 10, Name = "Ragby" }); foreach (var item in sections) { Console.WriteLine($"Name = {item.Name}, price = {item.Price}"); } }
/// <summary> /// Removes a custom section witht he specified name. /// </summary> public static bool RemoveCustomSection(string name) { return(CustomSections.Remove(GetCustomSection(name))); }
/// <summary> /// Gets a custom section that has the specified name. /// </summary> public static SectionModule GetCustomSection(string name) { return(CustomSections.FirstOrDefault(s => s.Name == name)); }