コード例 #1
0
        static void Main(string[] args)
        {
            string urunAdi  = "Elma";
            double fiyati   = 15;
            string aciklama = "Amasya alması";

            string[] meyveler = new string[] { "Elma", "Karpuz" };
            //Urun.urun1;
            Urun urun1 = new Urun();

            urun1.Adi      = "Elma";
            urun1.Fiyati   = 15;
            urun1.Aciklama = "Amasya elması";

            Urun urun2 = new Urun();

            urun2.Adi      = "Karpuz";
            urun2.Fiyati   = 80;
            urun2.Aciklama = "Diyarbakır karpuzu";

            Urun[] urunler = new Urun[] { urun1, urun2 };
            // foreach içindeki urun alias(takma isim)
            //type-safe -- tip güvenli
            // var da yazılsa olur Urun yerine
            foreach (Urun urun in urunler)
            {
                //<li>urun adi</li>
                Console.WriteLine(urun.Adi);
                Console.WriteLine(urun.Fiyati);
                Console.WriteLine(urun.Aciklama);
                Console.WriteLine("-------------------");
            }
            Console.WriteLine("--------------Metotlar--------------");
            //instance -  örnek
            //encapsulation - kapsülleme - düzene sokar

            sepetManager sepetmanager = new sepetManager();

            sepetmanager.Ekle(urun1);
            sepetmanager.Ekle(urun2);

            sepetmanager.Ekle2("Armut", "Yeşil armut", 12, 10);
            sepetmanager.Ekle2("Elma", "Yeşil elma", 12, 9);
            sepetmanager.Ekle2("Karpuz", "Diyarbakır karpuzu", 12, 8);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: metinkeskin/Kamp-ntro
        static void Main(string[] args)
        {
            product product1 = new product();

            product1.Adi      = " Elma";
            product1.Fiyati   = 15;
            product1.Aciklama = "Amasya elmasi";

            product product2 = new product();

            product2.Adi      = " Karpuz";
            product2.Fiyati   = 80;
            product2.Aciklama = "Diyarbakir karpuzu";

            product[] products = new product[] { product1, product2 };

            foreach (product product in products)
            {
                Console.WriteLine(product.Adi);
                Console.WriteLine(product.Fiyati);
                Console.WriteLine(product.Aciklama);
                Console.WriteLine("---------------");
            }

            Console.WriteLine("--------------metotlar-----------");

            //instance - ornek
            //encapsulation

            sepetManager sepetManager = new sepetManager();

            sepetManager.Ekle(product1);
            sepetManager.Ekle(product2);

            sepetManager.Ekle2("armut", "Yesil armut", 12, 9);
            sepetManager.Ekle2("elma", "Yesil elma", 12, 11);
            sepetManager.Ekle2("karpuz", "Dİyarbakır karpuzu", 12, 1);
        }