2009年12月23日水曜日

インターフェイスを実装して処理を実行してみる。

using System;


// インターフェイス
interface IPrintOut
{
    void printOut();
}
// 派生クラス
class DerivedClass : IPrintOut
{
    public void printOut()
    {
        Console.WriteLine("Interface");
    }
}
class MainClass
{
    static void Main()
    {
        DerivedClass drv = new DerivedClass();
        // 出力値:Interface
        drv.printOut();
    }
}

0 コメント:

コメントを投稿