コード例 #1
0
ファイル: ctest1.cs プロジェクト: CheneyWu/coreclr
        private static int Main()
        {
            Dictionary<object, int> myHT = new Dictionary<object, int>();

            CDerived1 c1 = new CDerived1();
            myHT.Add(c1, 1);

            CDerived2 c2 = new CDerived2();
            myHT.Add(c2, 2);

            CDerived3 c3 = new CDerived3();
            myHT.Add(c3, 3);

            CDerived4 c4 = new CDerived4();
            myHT.Add(c4, 4);

            CDerived5 c5 = new CDerived5();
            myHT.Add(c5, 5);

            CDerived6 c6 = new CDerived6();
            myHT.Add(c6, 6);

            CDerived7 c7 = new CDerived7();
            myHT.Add(c7, 7);

            CDerived8 c8 = new CDerived8();
            myHT.Add(c8, 8);

            CDerived9 c9 = new CDerived9();
            myHT.Add(c9, 9);

            CDerived10 c10 = new CDerived10();
            myHT.Add(c10, 10);

            CDerived11 c11 = new CDerived11();
            myHT.Add(c11, 11);

            CDerived12 c12 = new CDerived12();
            myHT.Add(c12, 12);

            CDerived13 c13 = new CDerived13();
            myHT.Add(c13, 13);

            CDerived14 c14 = new CDerived14();
            myHT.Add(c14, 14);

            CDerived15 c15 = new CDerived15();
            myHT.Add(c15, 15);

            CDerived16 c16 = new CDerived16();
            myHT.Add(c16, 16);

            CDerived17 c17 = new CDerived17();
            myHT.Add(c17, 17);

            CDerived18 c18 = new CDerived18();
            myHT.Add(c18, 18);

            CDerived19 c19 = new CDerived19();
            myHT.Add(c19, 19);

            CDerived20 c20 = new CDerived20();
            myHT.Add(c20, 20);

	    foreach (var item in myHT) {
	      if (item.Key.GetHashCode() != item.Value) {
		Console.WriteLine("FAILED at " + item.Value);
		return 1;
	      }
	    }

            Console.WriteLine("PASSED");
            return 100;
        }
コード例 #2
0
        private static int Main()
        {
            Dictionary <object, int> myHT = new Dictionary <object, int>();

            CDerived1 c1 = new CDerived1();

            myHT.Add(c1, 1);

            CDerived2 c2 = new CDerived2();

            myHT.Add(c2, 2);

            CDerived3 c3 = new CDerived3();

            myHT.Add(c3, 3);

            CDerived4 c4 = new CDerived4();

            myHT.Add(c4, 4);

            CDerived5 c5 = new CDerived5();

            myHT.Add(c5, 5);

            CDerived6 c6 = new CDerived6();

            myHT.Add(c6, 6);

            CDerived7 c7 = new CDerived7();

            myHT.Add(c7, 7);

            CDerived8 c8 = new CDerived8();

            myHT.Add(c8, 8);

            CDerived9 c9 = new CDerived9();

            myHT.Add(c9, 9);

            CDerived10 c10 = new CDerived10();

            myHT.Add(c10, 10);

            CDerived11 c11 = new CDerived11();

            myHT.Add(c11, 11);

            CDerived12 c12 = new CDerived12();

            myHT.Add(c12, 12);

            CDerived13 c13 = new CDerived13();

            myHT.Add(c13, 13);

            CDerived14 c14 = new CDerived14();

            myHT.Add(c14, 14);

            CDerived15 c15 = new CDerived15();

            myHT.Add(c15, 15);

            CDerived16 c16 = new CDerived16();

            myHT.Add(c16, 16);

            CDerived17 c17 = new CDerived17();

            myHT.Add(c17, 17);

            CDerived18 c18 = new CDerived18();

            myHT.Add(c18, 18);

            CDerived19 c19 = new CDerived19();

            myHT.Add(c19, 19);

            CDerived20 c20 = new CDerived20();

            myHT.Add(c20, 20);

            foreach (var item in myHT)
            {
                if (item.Key.GetHashCode() != item.Value)
                {
                    Console.WriteLine("FAILED at " + item.Value);
                    return(1);
                }
            }

            Console.WriteLine("PASSED");
            return(100);
        }