開発環境
- OS: Windows 10 Pro
- IDE(統合開発環境): Visual Studio Community 2017
Head First C# ―頭とからだで覚えるC#の基本 (Andrew Stellman (著)、Jennifer Greene (著)、佐藤 嘉一 (監修, 監修)、木下 哲也 (翻訳)、オライリージャパン)の7章(ファイルの読み書き - バイト配列を保存し、世界を救う)、StreamWriterマグネット(p. 285)を取り組んでみる。
コード
Program.cs
using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; using System.IO; namespace WindowsFormsApp20 { static class Program { /// <summary> /// アプリケーションのメイン エントリ ポイントです。 /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } } public class Flobbo { private string zap; public Flobbo(string zap) { this.zap = zap; } public StreamWriter snobbo() { return new StreamWriter("macaw.txt"); } public bool Blobbo(StreamWriter sw) { sw.WriteLine(zap); zap = "緑 紫"; return false; } public bool Blobbo(bool already, StreamWriter sw) { if (already) { sw.WriteLine(zap); sw.Close(); return false; } else { sw.WriteLine(zap); zap = "赤 オレンジ"; return true; } } } }
0 コメント:
コメントを投稿