private static void SaveGrades(IGradeTracker book) { using (StreamWriter outputFile = File.CreateText("grades.txt")) { book.WriteGrade(outputFile); } }
private static void SaveGrades(IGradeTracker book) { // using is used to dispose unneeded data if an unhandled error occurred. using (StreamWriter output = File.CreateText("Grades.txt"))// Create an empty text file with File.createText which returns data with StreamWriter type { //The WriteGrade method in GradeBook class expects data of StreamWriter type book.WriteGrade(output); // output.Close(); // This has to be used to save the data, as any type of Stream whether it is a FileStream or NetworkStream, // Streams has tendency for buffering } }
private static void AddGrades(IGradeTracker book) { book.AddGrade(91); book.AddGrade(45.5f); book.WriteGrade(Console.Out); }