開発環境
- Microsoft Windows 7 Home Premium (OS)
- Microsoft Visual C# 2010 Express Edition (IDE)
- 言語: C#
独習C# 第3版 ハーバート・シルト (著) エディフィストラーニング株式会社 矢嶋聡 (監修, 翻訳) の第9章(Cインターフェイス、構造体、列挙型)の理解度チェック8、9を解いてみる。
8.
クラスは参照型、構造体は値型。
9.
コード
using System; class Tester { enum Planets { Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune, } public void Run() { for (Planets p = Planets.Mercury; p < Planets.Neptune; p++) { Console.WriteLine("{0} has value of {1}", p, (int)p); } } static void Main() { Tester t = new Tester(); t.Run(); } }
入出力結果(Console Window)
Mercury has value of 0 Venus has value of 1 Earth has value of 2 Mars has value of 3 Jupiter has value of 4 Saturn has value of 5 Uranus has value of 6 続行するには何かキーを押してください . . .
0 コメント:
コメントを投稿