Exemple #1
0
 static void DiziYaz(Array dizi, BICIM b)
 {
     foreach (int i in dizi)
     {
         if (b == BICIM.DIKEY)
         {
             Console.WriteLine(i.ToString());
         }
         else
         {
             Console.Write(i.ToString() + " ");
         }
     }
 }
 public static void DiziYaz(Array dizi, BICIM b)
 {
     foreach (Object i in dizi)
     {
         if (b == BICIM.YATAY)
         {
             Console.Write(i.ToString() + " ");
         }
         else
         {
             Console.WriteLine(i.ToString());
         }
     }
     Console.WriteLine();
 }
 public static void Yaz(BICIM b, params object[] nesne)
 {
     if (nesne.Length == 0)
     {
         return;
     }
     if (b == BICIM.YATAY)
     {
         foreach (object o in nesne)
         {
             Console.Write(o.ToString() + " ");
         }
     }
     else
     {
         foreach (object o in nesne)
         {
             Console.WriteLine(o.ToString());
         }
     }
 }
Exemple #4
0
        static void Main(string[] args)
        {
            //     class Indexers
            // {
            //     public double sayi;
            //     public double this[double indeks]
            //     {
            //         get
            //         {
            //             return indeks * indeks;//sayi;//
            //         }
            //         set
            //         {
            //             sayi = value;
            //         }
            //     }


            // }
            Indexers indeks = new Indexers();

            Console.WriteLine("i[1.2]={0}", indeks[1.2]);
            indeks[5] = 2 * indeks[1.2];
            Console.WriteLine(indeks.sayi);
            indeks[6] = 9;
            indeks[6] = 8;
            indeks[7] = 8;
            indeks[8] = 8;
            Console.WriteLine(indeks[7].Equals(indeks[6]));
            Console.WriteLine(indeks.sayi.Equals(indeks.sayi));

            Console.WriteLine(indeks.sayi);
            Console.WriteLine("i[5]={0}", indeks[5]);
            Console.WriteLine("i[6]={0}", indeks[6]);
            Console.WriteLine("i[7]={0}", indeks[7]);
            Console.WriteLine("i[8]={0}", indeks[8]);



            IndeksIslem a = new IndeksIslem(7); // Burada dinamik boyutlu diziler tanımlıyoruz
            IndeksIslem b = new IndeksIslem(8);

            int[] z = new int[5];
            DiziYaz(z, BICIM.DIKEY);

            for (int j = 0; j < a.DiziBoyut; ++j) // burada DiziBoyut "Lenght" metodunun görevini görür bunu biz
                                                  // metot olarak IndeksIslem sınıfında tanımladık
            {
                a[j] = j + 1;                     // --> value => dizi[indeks] burada j+1 değerini x[j] ye atar
                b[j] = j + 2;
                Console.WriteLine($"x[{j}] = {a[j]}");
                Console.WriteLine($"y[{j}] = {b[j]}");
            }



            CokBoyutluIndexer c = new CokBoyutluIndexer(10, 8);

            for (int y = 0; y < c.Boyut1; ++y)
            {
                for (int x = 0; x < c.Boyut2; ++x)
                {
                    c[y, x] = y + x;
                }
            }


            for (int y = 0; y < c.Boyut1; ++y)
            {
                for (int x = 0; x < c.Boyut2; ++x)
                {
                    Console.Write("{0,4} ", c[y, x]);
                }
                Console.WriteLine();
            }

            string[] Gunler = HaftaninGunleri.GetNames(typeof(HaftaninGunleri));
            foreach (string g in Gunler)
            {
                Console.WriteLine(g);
            }


            string[] bicim = BICIM.GetNames(typeof(BICIM));
            foreach (string g in bicim)
            {
                Console.WriteLine("\n" + g);
            }

            CokBoyutluIndekser cb = new CokBoyutluIndekser(5, 4);

            for (int i = 0; i < cb.Boyut1; ++i)
            {
                for (int j = 0; j < cb.Boyut2; ++j)
                {
                    cb[i, j] = i * j;
                }
            }



            for (int i = 0; i < cb.Boyut1; ++i)
            {
                for (int j = 0; j < cb.Boyut2; ++j)
                {
                    Console.Write("{0,3}", cb[i, j]);
                }
                Console.WriteLine();
            }
            int [,] bi = new int[2, 2];
            Console.WriteLine(bi.GetLength(0));
        }