Esempio n. 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("***Use case-default keyword in generic programming:***");
            Console.WriteLine("***\nCreating an Integer store:***");
            MyStoreHouse <int> intStore = new MyStoreHouse <int>();

            intStore.AddToStore(45);
            intStore.AddToStore(75);
            Console.WriteLine("***Integer store at this moment:***");
            intStore.RetrieveFromStore();

            Console.WriteLine("***\nCreating an String store:***");
            MyStoreHouse <string> strStore = new MyStoreHouse <string>();

            strStore.AddToStore("abc");
            strStore.AddToStore("def");
            strStore.AddToStore("ghi");
            strStore.AddToStore("jkl");//Store is full already
            Console.WriteLine("***String store at this moment:***");
            strStore.RetrieveFromStore();
            Console.ReadKey();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("*** ジェネリックプログラムでキーワードdefaultを用いる事例 ***");
            Console.WriteLine("*** 変数の保管場所を作成 ***");
            MyStoreHouse <int> intStore = new MyStoreHouse <int>();

            intStore.AddToStore(45);
            intStore.AddToStore(75);
            Console.WriteLine("*** 今の整数保管場所の状況 ***");
            intStore.RetrieveFromStore();

            Console.WriteLine("*** 文字列の保管場所を作成 ***");
            MyStoreHouse <string> strStore = new MyStoreHouse <string>();

            strStore.AddToStore("abc");
            strStore.AddToStore("def");
            strStore.AddToStore("ghi");
            strStore.AddToStore("jkl"); // 保管場所はもう一杯です
            Console.WriteLine("*** 今の文字列の保管場所の状況 ***");
            strStore.RetrieveFromStore();
            Console.ReadKey();
        }