開発環境
- OS: macOS High Sierra - Apple
- IDE(統合開発環境): Visual Studio for Mac
- プログラミング言語: C#
初めてのC# 第2版 (Jesse Liberty (著)、Brian MacDonald (著)、日向 俊二 (翻訳)、オライリージャパン)の6章(オブジェクト指向プログラミング)、6.8(練習問題)、練習6.2を取り組んでみる。
コード
using System;
namespace Sample6_2
{
class Program
{
static void Main(string[] args)
{
Book book = new Book();
book.read();
book.shelve();
}
}
class Book
{
string title = "書名";
string author = "著者";
long isbn = 1234567890123;
public void read()
{
Console.WriteLine("本を読む。{0}, {1}, {2}", title, author, isbn);
}
public void shelve()
{
Console.WriteLine("書棚に保管する。");
}
}
}
入出力結果(Terminal)
本を読む。書名, 著者, 1234567890123 書棚に保管する。 Press any key to continue...
0 コメント:
コメントを投稿