static void Main(string[] args) { try { Mylist <Product> product1 = new Mylist <Product>(); Product prod1 = new Product("Банан", 100, 100); Product prod2 = new Product("Яблоко", 150, 90); product1.AddItem(prod1); product1.AddItem(prod2); Console.WriteLine(product1); Console.WriteLine(); product1.Show(); FileStream file = new FileStream("d:\\kurs\\LABS\\infotext.txt", FileMode.Create); StreamWriter writer = new StreamWriter(file); writer.Write(prod1.ToString()); writer.Write("\n"); writer.Write(prod2.ToString()); writer.Write("\n"); writer.Close(); FileStream file1 = new FileStream("d:\\kurs\\LABS\\infotext.txt", FileMode.Open); StreamReader reader = new StreamReader(file); Console.WriteLine(reader.ReadToEnd()); reader.Close(); } finally { Console.WriteLine("End"); } }
public static Mylist <T> operator +(Mylist <T> list, Mylist <T> Item) { Mylist <T> result = new Mylist <T>(); foreach (T item in list) { result.AddItem(item); } foreach (T item in Item) { result.AddItem(item); } return(result); }