Класс "Автомобиль". Создать метод, сохраняющий всю информацию в отдельный текстовый файл - C#
Формулировка задачи:
Листинг программы
- using System;
- using System.IO;
- namespace Работа_с_объектами.лабораторная_работа__2
- {
- class Program
- {
- static void Main(string[] args)
- {
- Ccar car = new Ccar();
- car.Save("E:\\New Folder","E:\\New Folder\\text.txt");
- Console.ReadKey();
- }
- }
- class Ccar
- {
- public string brand = "BMW";
- public string model = "GT";
- public string releaseDate = "19.25.2005";
- public double engine = 3.5;
- public string color = "Blue";
- public void Save(string directory, string text)
- {
- DirectoryInfo k = new DirectoryInfo(directory);
- k.Create();
- StreamWriter stream = new StreamWriter(text);
- stream.Write(brand, model, releaseDate, engine, color);
- stream.Close();
- }
- }
- }
Решение задачи: «Класс "Автомобиль". Создать метод, сохраняющий всю информацию в отдельный текстовый файл»
textual
Листинг программы
- stream.Write("{0} {1} {2} {3} {4}",brand, model, releaseDate, engine, color);
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д