using System.Collections.Generic; using System.IO; namespace MobileApp { class Program { static void Main(string[] args) { // Creating a list of mobile objects ListmobileList = new List (); mobileList.Add(new Mobile("Nokia", "3310", 5000)); mobileList.Add(new Mobile("Samsung", "Galaxy S20", 120000)); // Writing the list of mobile objects to a file using (TextWriter writer = new StreamWriter("mobilelist.txt")) { GenericWriter.WriteMobileList (writer, mobileList); } } } }
using System.Collections.Generic; using System.IO; namespace MobileApp { class Program { static void Main(string[] args) { // Creating a list of mobile objects ListThe package library for the GenericWriter class is not specified as it could be included in any C# library that provides generic serialization functionalities.mobileList = new List (); mobileList.Add(new Mobile("Nokia", "3310", 5000)); mobileList.Add(new Mobile("Samsung", "Galaxy S20", 120000)); // Writing the list of mobile objects to a memory stream MemoryStream memoryStream = new MemoryStream(); using (TextWriter writer = new StreamWriter(memoryStream)) { GenericWriter.WriteMobileList (writer, mobileList); } } } }