Beispiel #1
0
        static void Main()
        {
            IndexedNames names = new IndexedNames();

            names[0] = "Zara";
            names[1] = "Riz";
            names[2] = "Nuha";
            names[3] = "Asif";
            names[4] = "Davinder";
            names[5] = "Sunil";
            names[6] = "Rubic";

            //for (int i = 0; i < names.nameList.Length; i++)
            //{
            //    Console.WriteLine(names[i]);
            //}

            // 使用带有 int 参数的第一个索引器
            //for (int i = 0; i < IndexedNames.size; i++)
            //{
            //    Console.WriteLine(names[i]);
            //}

            // 使用带有 string 参数的第二个索引器
            //Console.WriteLine(names["Nuha"]);
            for (int i = IndexedNames.size - 1; i >= 0; i--)
            {
                Console.WriteLine(names[i] + " " + names[names[i]]);
            }

            Console.ReadKey();
        }
Beispiel #2
0
        static void Main(string[] args)

        {
            IndexedNames names = new IndexedNames();

            names[0] = "Zara";

            names[1] = "Riz";

            names[2] = "Nuha";

            names[3] = "Asif";

            names[4] = "Davinder";

            names[5] = "Sunil";

            names[6] = "Rubic";



            for (int i = 0; i < IndexedNames.size; i++)

            {
                Console.WriteLine(names[i]);
            }

            Console.ReadKey();
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            IndexedNames names = new IndexedNames();

            names[0] = "Rahul";
            names[1] = "Sharad";
            names[2] = "Nimish";
            names[3] = "Ninja";
            names[4] = "Shabnam";
            names[5] = "Shivam";
            names[6] = "Zara";
            for (int i = 0; i < IndexedNames.size; i++)
            {
                Console.WriteLine(names[i]);
            }
            Console.ReadKey();
        }
Beispiel #4
0
        static void Main(string [] args)
        {
            IndexedNames names = new IndexedNames();

            names[0] = "sasr ";
            names[1] = " zhuliye";
            names[3] = " wanganshi";
            names[4] = "wuyanzu ";
            names[5] = "pengyuyan ";
            names[6] = "sanbian";
            names[7] = "quannazou ";
            for (int i = 0; i < IndexedNames.size; i++)
            {
                Console.WriteLine(names[i]);
            }
            Console.WriteLine(names["sanbian"]);//string index if aim string exit ,return the Number of this string
            Console.ReadKey();
        }
 static void Main(string[] args)
 {
     IndexedNames names = new IndexedNames();
     names[0] = "Zara";
     names[1] = "Riz";
     names[2] = "Nuha";
     names[3] = "Asif";
     names[4] = "Davinder";
     names[5] = "Sunil";
     names[6] = "Rubic";
     //using the first indexer with int parameter
     for (int i = 0; i < IndexedNames.size; i++)
     {
         Console.WriteLine(names[i]);
     }
     //using the second indexer with the string parameter
     Console.WriteLine(names["Nuha"]);
     Console.ReadKey();
 }
Beispiel #6
0
        static void Main(string[] args)
        {
            IndexedNames names = new IndexedNames();

            names[0] = "Zara";
            names[1] = "Riz";
            names[2] = "Nuha";
            names[3] = "Asif";
            names[4] = "Davinder";
            names[5] = "Sunil";
            names[6] = "Rubic";
            //using the first indexer with int parameter
            for (int i = 0; i < IndexedNames.size; i++)
            {
                Console.WriteLine(names[i]);
            }
            //using the second indexer with the string parameter
            Console.WriteLine(names["Nuha"]);
            Console.ReadKey();
        }
Beispiel #7
0
        static void Main(string[] args)
        {
            IndexedNames names = new IndexedNames();

            names[0] = "Maxsu";
            names[1] = "Sukida";
            names[2] = "Mark";
            names[3] = "Jame";
            names[4] = "Davinder";
            names[5] = "Lucy";
            names[6] = "Lily";

            for (int i = 0; i < IndexedNames.size; i++)
            {
                WriteLine(names[i]);
            }

            WriteLine(names["Mark"]);
            WriteLine(names["Lily"]);
            WriteLine(names["popo"]);
            WriteLine(names["none"]);

            ReadKey();
        }