開発環境
- OS: Windows 10 Pro
- IDE(統合開発環境): Visual Studio Community 2017
初めてのC# 第2版 (Jesse Liberty (著)、Brian MacDonald (著)、日向 俊二 (翻訳)、オライリージャパン)の6章(オブジェクト指向プログラミング)、6.8(練習問題)、問題6.2.を取り組んでみる。
コード
using System; namespace ConsoleApp1 { class Book { private string title; private string author; private string isbn; public Book(string title, string author, string isbn) { this.title = title; this.author = author; this.isbn = isbn; } public void Shelve() { Console.WriteLine("{0}を書棚に保管する。", this); } public override string ToString() { return "「" + title + "」"; } } class Program { static void Main(string[] args) { Book book = new Book( "初めてのC#", "Jesse Liberty, Brian MacDonald", "487311294"); book.Shelve(); } } }
入出力結果(Terminal)
「初めてのC#」を書棚に保管する。 続行するには何かキーを押してください . . .
0 コメント:
コメントを投稿