2012年10月1日月曜日

開発環境

『初めてのC# 第2版』(Jesse Liberty+Brian MacDonald著、日向俊二訳、オライリー・ジャパン、2006年、ISBN978-487311-294-7)の 第3章(C#言語の基礎)3.10(練習問題)問題3-2を解いてみる。

その他参考書籍

問題3-2.

コード

using System;

class Tester
{
    public void Run()
    {
        int a = 10;
        float b = 1.2f;
        double c = 12345.6789;
        char d = 'k';
        Console.WriteLine("変更前");
        Console.WriteLine("int型: {0}\nfloat型: {1}\ndouble型: {2}\nchar型: {3}",
            a, b, c, d);
        a = 20;
        b = 2.3f;
        c = 9876.54321;
        d = 'K';
        Console.WriteLine("変更後");
        Console.WriteLine("int型: {0}\nfloat型: {1}\ndouble型: {2}\nchar型: {3}",
            a, b, c, d);
    }
    static void Main()
    {
        Tester t = new Tester();
        t.Run();
    }
}

入出力結果(Console Window)

変更前
int型: 10
float型: 1.2
double型: 12345.6789
char型: k
変更後
int型: 20
float型: 2.3
double型: 9876.54321
char型: K
続行するには何かキーを押してください . . .

0 コメント:

コメントを投稿