示例#1
0
        public static void SaveToFile(string directoryPath, string fileName, CourseReport report)
        {
            if (!Directory.Exists(directoryPath))
            {
                Directory.CreateDirectory(directoryPath);
            }

            File.WriteAllText(Path.Combine(directoryPath, fileName), report.ToString());
        }
示例#2
0
        static void Main(string[] args)
        {
            var report = new CourseReport();

            report.AddEntry(new CourseReportEntry {
                Name = "Patrones de diseño", Students = 1000, Rating = 5
            });
            report.AddEntry(new CourseReportEntry {
                Name = "Flutter", Students = 1900, Rating = 4.5
            });
            report.AddEntry(new CourseReportEntry {
                Name = "Universidad de Java", Students = 4344, Rating = 4.0
            });

            Console.WriteLine(report.ToString());

            FileSaver.SaveToFile(@"Reports", "WorkReport.txt", report);
        }