Csharp Grsel Kontrller Asl Ergn C GRSEL KONTRLLER

  • Slides: 51
Download presentation
Csharp Görsel Kontröller Aslı Ergün

Csharp Görsel Kontröller Aslı Ergün

C# GÖRSEL KONTRÖLLERİ • • • Message. Box Button Text. Box Label Combo. Box

C# GÖRSEL KONTRÖLLERİ • • • Message. Box Button Text. Box Label Combo. Box List. Box

 • Message. Box, kullanıcıya bilgi göstermek için açılan mesaj kutusudur. Bu mesaj kutusu

• Message. Box, kullanıcıya bilgi göstermek için açılan mesaj kutusudur. Bu mesaj kutusu dört öğeden oluşur. · Text (Yazı): Mesaj kutusunda verilmek istenen bilgiyi tutan yazıdır · Caption (Başlık): Mesaj kutusunun başlığıdır · Buttons (Düğmeler): Mesaj kutusunda hangi düğmelerin gösterileceğini belirler. · Icon (Simge): Mesaj kutusunda gösterilecek olan simgeyi ve açıldığı zaman çıkartılacak sesi belirler. Message. Box. Show("Devam etmek istiyor musunuz? ", "Uyarı", Message. Box. Buttons. Yes. No, Message. Box. Icon. Warning); • Mesaj kutusu, kapanırken hangi düğmenin basıldığını Dialog. Result nesnesi ile programcıya bildirir. if(Message. Box. Show("Değişiklikler kaydedilsin mi? ", "Kayıt", Message. Box. Buttons. Yes. No. Cancel) == Dialog. Result. Cancel) { // İptal tuşuna basıldığı zaman // buraya girilir. }

Button • Bir Windows düğmesini temsil eder. Button kontrolüne basıldığında Click olayı tetiklenir. Bu

Button • Bir Windows düğmesini temsil eder. Button kontrolüne basıldığında Click olayı tetiklenir. Bu olay gerçekleştiği zaman yapılacak işlemler, Button. Ismi_Click yordamında yazılır. private void btn. Renk. Degistir_Click(object sender, System. Event. Args e) { btn. Renk. Degistir. Fore. Color = Color. Gray; }

Daire Alan Çevresi • Dairenin alan , çevre ve yay uzunluklarını bulun. Alan =

Daire Alan Çevresi • Dairenin alan , çevre ve yay uzunluklarını bulun. Alan = Pi * R 2 Çevre=2*Pi*R Yay uzunluğu = (derece – 2*Pi*R)/360 formülleri ile bulunur.

Text. Box • Bir Windows metin kutusunu temsil eder. Kullanıcıların değer girerek program ile

Text. Box • Bir Windows metin kutusunu temsil eder. Kullanıcıların değer girerek program ile haberleşmesini sağlamak amacıyla kullanılır. Text. Box kontrolündeki yazı değiştiği zaman Text. Changed olayı gerçekleşir. private void text. Box 1_Text. Changed(object sender, System. Event. Args e) { // Text. Box içindeki yazı değiştiği zaman // aşağıdaki kod çalışır. Message. Box. Show("Yazı değiştirildi: " + text. Box 1. Text); }

Label • Bir Windows etiketini temsil eder. Kullanıcıya, form üzerinde bir yazıyı göstermek amaçlı

Label • Bir Windows etiketini temsil eder. Kullanıcıya, form üzerinde bir yazıyı göstermek amaçlı kullanılır. Bu yazının görünümü, Label kontrolünün bazı özellikleri ile değiştirilir. Text. Align (Yazı Hizalama) Yazının Label kontrolü üzerinde nerede duracağını belirler. Font (Yazı Tipi) Font özelliği birçok alt özellik taşır. Bunlardan bazıları en sık kullanılan özelliklerdir. Name Yazı tipinin ismini belirler. Varsayılan Microsoft Sans Serif seçilidir. Size Karakterlerin boyutunu belirler. Varsayılan büyüklük 8, 5 değerini alır. Bold (Kalın) Yazının kalın tipte olmasını belirler. Italic (Yatay) Yazının italik tipte olmasını belirler. Under. Line (Altı Çizgili) Yazının altı çizgili olmasını belirler.

Radiobutton • • Bir Windows radyo düğmeli seçme nesnesini temsil eder. radio. Button 1.

Radiobutton • • Bir Windows radyo düğmeli seçme nesnesini temsil eder. radio. Button 1. Checked = true; kontrolu ile seçim yapılıp yapılmadığı kontrol edilir.

Checkbox • • Bir Windows kutu halinde birden çok seçme nesnesini temsil eder. check.

Checkbox • • Bir Windows kutu halinde birden çok seçme nesnesini temsil eder. check. Box 1. Checked = true; kontrolu ile seçim yapılıp yapılmadığı kontrol edilir.

Combo. Box • Bir Windows açılan kutusunu temsil eder. Combo. Box kontrolü, kullanıcıların bazı

Combo. Box • Bir Windows açılan kutusunu temsil eder. Combo. Box kontrolü, kullanıcıların bazı değerleri açılan bir listeden seçmesini sağlar. Listeye tasarım anında veya çalışma anında öğe eklenebilir. Listeye öğe eklemek için kontrolün Items özelliğinden faydalanılır. Tasarım anında öğe eklemek için Properties panelinden Items özelliği seçilir. String Collection Editor penceresinde, her öğenin değeri tek bir satırda yazılır.

Combo. Box-2 • Çalışma anında öğe eklemek için kod sayfasında, kontrolün Items özelliğinin Add

Combo. Box-2 • Çalışma anında öğe eklemek için kod sayfasında, kontrolün Items özelliğinin Add metodu kullanılır. private void Form 1_Load(object sender, System. Event. Args e) { combo. Box 1. Items. Add("Lise"); combo. Box 1. Items. Add("Üniversite"); combo. Box 1. Items. Add("Yüksek Lisans"); combo. Box 1. Items. Add("Doktora"); }

List. Box • Bir Windows liste kutusunu temsil eder. Kontroldeki öğeler sabit bir liste

List. Box • Bir Windows liste kutusunu temsil eder. Kontroldeki öğeler sabit bir liste olarak görüntülenir. List. Box kontrolüne öğe ekleme işlemi, Combo. Box kontrolündeki işlemlere ile aynıdır. Combo. Box kontrolünden farkı, birden fazla öğe seçilebilir olmasıdır. private void btn. Bos. Siniflar_Click(object sender, System. Event. Args e) { list. Box 1. Items. Add("YU 6501"); list. Box 1. Items. Add("YM 6221"); list. Box 1. Items. Add("YM 6102"); list. Box 1. Items. Add("YU 6412"); }

Listbox Arası Veri Değişimi namespace derskredi { public partial class Form 1 : Form

Listbox Arası Veri Değişimi namespace derskredi { public partial class Form 1 : Form { int kredi = 0; public Form 1() { Initialize. Component(); } private void button 1_Click(object sender, Event. Args e) { list. Box 2. Items. Add(list. Box 1. Text); list. Box 1. Items. Remove(list. Box 1. Text); kredi = kredi + 2; text. Box 1. Text = kredi. To. String(); int i=1; Message. Box. Show(list. Box 1. Items[2]. To. String() ); Message. Box. Show(list. Box 1. Items. Count. To. Stri ng()); if (list. Box 1. Items. Contains("Programlama")) Message. Box. Show("test 1"); if (list. Box 1. Items[5]. Equals("micro")) Message. Box. Show("test 2"); }

Derskredi-devam private void button 2_Click(object sender, Event. Args e) { list. Box 1. Items.

Derskredi-devam private void button 2_Click(object sender, Event. Args e) { list. Box 1. Items. Add(list. Box 2. Te xt); list. Box 2. Items. Remove(list. Box 2. Text); kredi -= 2; // kredi = kredi -2; text. Box 1. Text = kredi. To. String(); } } }

Direnç Hesaplama • • • namespace direnc { public partial class Form 1 :

Direnç Hesaplama • • • namespace direnc { public partial class Form 1 : Form { double toplamdirenc = 0. 0; double toplamlar=0. 0; double carpimlar = 1; public Form 1() { Initialize. Component(); } • private void button 1_Click(object sender, Event. Args e) { list. Box 2. Items. Add(list. Box 1. Text); list. Box 1. Items. Remove(list. Box 1. Text); } • • • private void button 2_Click(object sender, Event. Args e) { list. Box 1. Items. Add(list. Box 2. Text); list. Box 2. Items. Remove(list. Box 2. Text); }

Direnc-devam • • • • private void button 3_Click(object sender, Event. Args e) {

Direnc-devam • • • • private void button 3_Click(object sender, Event. Args e) { toplamdirenc = 0. 0; if (radio. Button 1. Checked) // seri { for(int i=0; i< list. Box 2. Items. Count; i++) { toplamdirenc += Convert. To. Double(list. Box 2. Items[i]. To. Stri ng()); } } else // paralel { for (int i = 0; i < list. Box 2. Items. Count; i++) { • • toplamlar += Convert. To. Double(list. Box 2. Items[i]. To. Stri ng()); carpimlar *= Convert. To. Double(list. Box 2. Items[i]. To. Stri ng()); } toplamdirenc = carpimlar / toplamlar; } • • • text. Box 1. Text = toplamdirenc. To. String(); } } }

Trackbar • private void button 3_Click(object sender, Event. Args e) { track. Bar 1.

Trackbar • private void button 3_Click(object sender, Event. Args e) { track. Bar 1. Minimum = 0; track. Bar 1. Maximum = 15; Message. Box. Show(track. Bar 1. Value. To. Stri ng()); }

Progressbar • private void button 4_Click(object sender, Event. Args e) • { • progress.

Progressbar • private void button 4_Click(object sender, Event. Args e) • { • progress. Bar 1. Minimum = 0; • progress. Bar 1. Maximum = 30000; • for (int i = progress. Bar 1. Minimum; i <= progress. Bar 1. Maximum; i++) • progress. Bar 1. Value = i; • }

Fonksiyonlar(C#) private static int usalma(int sayi, int us) { int i, sonuc = 1;

Fonksiyonlar(C#) private static int usalma(int sayi, int us) { int i, sonuc = 1; for (i = 1; i<us+1 ; i++) { sonuc = sonuc * sayi; } return sonuc; } private void button 1_Click(object sender, Event. Args e) { int s, u; s = int. Parse(text. Box 1. Text); u = int. Parse(text. Box 2. Text); label 1. Text = usalma(s, u). To. String(); }

Fonksiyonlar using System; using System. Collections. Generic; using System. Component. Model; using System. Data;

Fonksiyonlar using System; using System. Collections. Generic; using System. Component. Model; using System. Data; using System. Drawing; using System. Linq; using System. Text; using System. Windows. Forms; namespace fonsiyon 1 { public partial class Form 1 : Form { double sayi 1, sayi 2, sonuc; public double toplam (double a, double b) { double c; c = 2* a + 3* b; return c; } public Form 1() { Initialize. Component(); } private void button 1_Click(object sender, Event. Args e) { sayi 1 = Convert. To. Double(text. Box 1. Text); sayi 2 = Convert. To. Double(text. Box 2. Text); sonuc = toplam(sayi 1, sayi 2); text. Box 3. Text = sonuc. To. String(); } } }

Fonksiyon namespace Windows. Forms. Application 1 { public partial class Form 1 : Form

Fonksiyon namespace Windows. Forms. Application 1 { public partial class Form 1 : Form { public Form 1() { Initialize. Component(); } private void button 1_Click(object sender, Event. Args e) { string okunan = text. Box 1. Text; double derece = Convert. To. Double( okunan); derece = ((derece * 1. 8) + 32); serial. Port 1. Write. Line(derece. To. String()); } public double cevirfahrensantigrat(string okunan) { double derece = Convert. To. Double(okunan); derece = ((derece - 32) / 1. 8); return derece; } private void serial. Port 1_Data. Received(object sender, System. IO. Ports. Serial. Data. Received. Event. Args e) { } e) private void Form 1_Load(object sender, Event. Args { private void button 2_Click(object sender, Event. Args e) { serial. Port 1. Port. Name = "COM 1"; if (serial. Port 1. Is. Open == false) serial. Port 1. Open(); } } string okunan = serial. Port 1. Read. Existing(); double sonuc= cevirfahrensantigrat(okunan); text. Box 1. Text = sonuc. To. String();

Arduino-Function void setup(){ Serial. begin(9600); } void loop() { int i = 2; int

Arduino-Function void setup(){ Serial. begin(9600); } void loop() { int i = 2; int j = 3; int k; k = my. Multiply. Function(i, j); Serial. println(k); delay(500); } int my. Multiply. Function(int x, int y){ int result; result = x * y; return result; } void loop() { int sens; sens = Read. Sens_and_Condition(); } int Read. Sens_and_Condition(){ int i; int sval = 0; for (i = 0; i < 5; i++){ sval = sval + analog. Read(0); // sensor on analog pin 0 } sval = sval / 5; // average sval = sval / 4; // scale to 8 bits (0 - 255) sval = 255 - sval; // invert output return sval; }

Çift ve Tek Sayıların Toplamı using System; using System. Collections. Generic; using System. Text;

Çift ve Tek Sayıların Toplamı using System; using System. Collections. Generic; using System. Text; namespace fordongusu { class Program { static void Main(string[] args) { int tektoplam=0, cifttoplam=0; for (int i = 1; i < 21; i++) { if (i % 2 == 0) cifttoplam = cifttoplam + i; else tektoplam = tektoplam + i; } Console. Write. Line("tek sayýlarýn toplamý= {0} , cift sayýlarýn toplamý= {1}", tektoplam, cifttoplam); } } }

1000 e kadar 5 ve 7 ye tam bölünenlerin toplamı using System; using System.

1000 e kadar 5 ve 7 ye tam bölünenlerin toplamı using System; using System. Collections. Generic; using System. Text; namespace toplam 5 ve 7 { class Program { static void Main(string[] args) { int toplam = 0; for (int i = 1; i < 1000; i++) { if ((i % 5 == 0) && (i % 7 == 0)) { Console. Write(i + " "); toplam += i; } } Console. Write("toplam = {0}", toplam); } } }

Yıldız Patern using System; using System. Collections. Generic; using System. Text; namespace yildiz {

Yıldız Patern using System; using System. Collections. Generic; using System. Text; namespace yildiz { class Program { static void Main(string[] args) { for (int i =7; i > 0; i--) { for (int j = 0; j < i; j++) { Console. Write("*"); } Console. Write. Line("") ; } }

Rasgele Sayı Üretme using System; using System. Collections. Generic; using System. Text; namespace rasgelesayi

Rasgele Sayı Üretme using System; using System. Collections. Generic; using System. Text; namespace rasgelesayi { class Program { static void Main(string[] args) { int sayi 1; int sayi 2; Random rasgele = new Random(); sayi 1 = rasgele. Next(1, 200); Console. Write. Line(sayi 1. To. String()); } } }

Diziler • İnt sayi[] = new int[5]; • İnt sayi[]= {0, 1, 2, 3,

Diziler • İnt sayi[] = new int[5]; • İnt sayi[]= {0, 1, 2, 3, 4}; • double[, ] dizi = new int[5, 5]; double[, ] dizi = {{. . }, . . . };

100 rasgele sayı ortalaması

100 rasgele sayı ortalaması

Ortalama Bulma-Dizi olmadan using System; using System. Collections. Generic; using System. Text; namespace ornek

Ortalama Bulma-Dizi olmadan using System; using System. Collections. Generic; using System. Text; namespace ornek 5 { class Program { static void Main(string[] args) { int sayi, min=999, max=0, ortalama, toplam=0; // 10 sayi gir, sayılar 0 -100 arası olsun // ekrana min, max, ortalama for (int i = 1; i <= 10; i++) { Console. Write(" Sayiyi girin: "); sayi = int. Parse(Console. Read. Line()); // sayi = Convert. To. Int 16(Console. Read. Line()); // sayi = System. Int 16. Parse(Console. Read. Line()); if ((sayi <= 100) && (sayi >= 0)) { toplam = toplam + sayi; if (sayi < min) min = sayi; if (sayi > max) max = sayi; } else { Console. Write. Line("hatalı giris"); i--; } } ortalama = toplam / 10; Console. Write. Line("Minimum deger = {0}", min); Console. Write. Line("Maximum deger = " + max); Console. Write. Line("Ortalama = " + ortalama); } } }

Struct (Yapı) Tanımları • Aralarında mantıksal bir ilişki bulunan farklı türden bilgilerin tanımlandığı ve

Struct (Yapı) Tanımları • Aralarında mantıksal bir ilişki bulunan farklı türden bilgilerin tanımlandığı ve üstlerinde işlemlerin yapıldığı yapılardır. Struct dogumtarihi { public string gun; public string yil; public string ay; } struct otomobil { public string model; public int motor. Hacmi; public bool otomatik. Vites; public string renk; } bmw otomobil = new otomobil(); // veya otomobil bmw; bmw. model = "Tourer"; bmw. motor. Hacmi = 2000; bmw. otomatik. Vites = true; bmw. renk = "Gümüş";

Araba Galeri –dizi ve struct ornek namespace arabakiralama { public struct arabakayit { public

Araba Galeri –dizi ve struct ornek namespace arabakiralama { public struct arabakayit { public string yapim; public string model; public string yili; public string resim; }; public partial class Form 1 : Form { //public arabakayit araba = new arabakayit(); public arabakayit[] arabalar = new arabakayit[20]; int index; int elemansayisi = 3; public Form 1() { Initialize. Component(); } private void button 1_Click(object sender, Event. Args e) { if (index > 0) index--; else index = elemansayisi-1; text. Box 1. Text = arabalar[index]. yapim; text. Box 2. Text = arabalar[index]. model; text. Box 3. Text = arabalar[index]. yili; picture. Box 1. Image = Image. From. File(arabalar[index]. resim); // picture. Box 1. Image = new Bitmap("D: \cars\Civic. jpg"); }

Dizi-arabagaleri-devam private void Form 1_Load(object sender, Event. Args e) { arabalar[0]. yapim = "Honda";

Dizi-arabagaleri-devam private void Form 1_Load(object sender, Event. Args e) { arabalar[0]. yapim = "Honda"; arabalar[0]. model = "Civic"; arabalar[0]. yili = "2005"; arabalar[0]. resim = "D: \cars\Civic. jpg"; arabalar[1]. yapim = "Ford"; arabalar[1]. model ="Escape"; arabalar[1]. yili ="2008"; arabalar[1]. resim = "D: \cars\ford_escape. jpeg"; arabalar[2]. yapim = "Renault"; arabalar[2]. model = "Clio"; arabalar[2]. yili = "2010"; arabalar[2]. resim = "D: \cars\renaultclio. jpg"; index = 0; text. Box 1. Text = arabalar[index]. yapim; text. Box 2. Text = arabalar[index]. model; text. Box 3. Text = arabalar[index]. yili; picture. Box 1. Image = Image. From. File(arabalar[index]. resim); // picture. Box 1. Image = new Bitmap("D: \cars\Civic. jpg"); } private void button 2_Click(object sender, Event. Args e) { if (index <2) index++; else index =0; text. Box 1. Text = arabalar[index]. yapim; text. Box 2. Text = arabalar[index]. model; text. Box 3. Text = arabalar[index]. yili; picture. Box 1. Image = Image. From. File(arabalar[index]. resim); } private void track. Bar 1_Scroll(object sender, Event. Args e) { index = track. Bar 1. Value; if (index > 2) index =2; text. Box 1. Text = arabalar[index]. yapim; text. Box 2. Text = arabalar[index]. model; text. Box 3. Text = arabalar[index]. yili; picture. Box 1. Image = Image. From. File(arabalar[index]. resim); } } }

Araba Kiralama namespace arabakiralama { public struct kayit { public long numara; public string

Araba Kiralama namespace arabakiralama { public struct kayit { public long numara; public string model; public double km; public int yil; public string renk; public double ucret; }; public partial class Form 1 : Form { public kayit araba = new kayit(); kayit[] arabalar = new kayit[20]; int index = 0; //dizide ekleme gostergesi int sayac = 0; public Form 1() { Initialize. Component(); }

private void button 2_Click(object sender, Event. Args e) { private void button 1_Click(object sender,

private void button 2_Click(object sender, Event. Args e) { private void button 1_Click(object sender, Event. Args e) { araba. numara = Convert. To. Int 32(text. Box 2. Text); araba. model = text. Box 1. Text; araba. km = Convert. To. Double(text. Box 3. Text); araba. yil = Convert. To. Int 16(text. Box 4. Text); araba. renk = text. Box 5. Text; araba. ucret = Convert. To. Double(text. Box 6. Text); text. Box 1. Text = arabalar[sayac]. model; text. Box 2. Text = arabalar[sayac]. numara. To. String(); text. Box 3. Text = arabalar[sayac]. km. To. String(); text. Box 4. Text = arabalar[sayac]. yil. To. String(); text. Box 5. Text = arabalar[sayac]. renk; text. Box 6. Text = arabalar[sayac]. ucret. To. String(); sayac++; if (sayac == index) sayac = 0; arabalar[index]. numara = araba. numara; arabalar[index]. model = araba. model; arabalar[index]. km = araba. km; arabalar[index]. yil = araba. yil; arabalar[index]. renk = araba. renk; arabalar[index]. ucret = araba. ucret; text. Box 1. Text = ""; text. Box 2. Text = ""; text. Box 3. Text = ""; text. Box 4. Text = ""; text. Box 5. Text = ""; text. Box 6. Text = ""; if (index <19) index++; } } private void button 3_Click(object sender, Event. Args e) { Close(); // this. close(); } private void Form 1_Load(object sender, Event. Args e) { } } }

Deprem Sigortası Bir sigorta sirketi aşağıdaki formül uyarınca deprem sigortası yapmaktadır. Listbox icinde yapı

Deprem Sigortası Bir sigorta sirketi aşağıdaki formül uyarınca deprem sigortası yapmaktadır. Listbox icinde yapı tarzı (celik, kagir ve diger) girilecektir. ) Deprem sigortasını hesaplayan programı yazın. Depremsigortası = sigortalanacak yil * ((bina yasi*300)+ deprembolgekatsayisi) Deprembolge katsayisi soyle belirlenir: Yapi tarzi/deprembolg esi 1. bolge(riskli) 2. bolge(az riskli) 3. bolge(risksiz) Celik 2 1. 5 1 Kagir(ahsap) 2. 5 2 1. 5 Diger 3 2. 5 2

Deprem Sigortası-2 using System; using System. Collections. Generic; using System. Component. Model; using System.

Deprem Sigortası-2 using System; using System. Collections. Generic; using System. Component. Model; using System. Data; using System. Drawing; using System. Text; using System. Windows. Forms; private void button 1_Click(object sender, Event. Args e) { int i, j; // i= satýr j=sütun katsayi[i, j] j = 0; yil = Convert. To. Int 16(text. Box 1. Text); yas = System. Int 16. Parse(text. Box 2. Text); namespace deprem { public partial class Form 1 : Form { double[, ] katsayi= new double[3, 3] {{2. 0, 1. 5, 1. 0}, {2. 5, 2. 0, 1. 5}, {3. 0, 2. 5, 2. 0}}; double sigorta; int yil, yas; // if (list. Box 1. Text. Equals("Çelik")) i=0; // if (list. Box 1. Selected. Index == 0 ) i=0; i= list. Box 1. Selected. Index; if (radio. Button 1. Checked == true) j = 0; if (radio. Button 2. Checked == true) j = 1; if (radio. Button 3. Checked == true) j = 2; public Form 1() { Initialize. Component(); } private void Form 1_Load(object sender, Event. Args e) { list. Box 1. Items. Add("Çelik"); list. Box 1. Items. Add("Kagir"); list. Box 1. Items. Add("Diðer"); } sigorta = yil * (yas*300)+ katsayi[i, j]; text. Box 3. Text = sigorta. To. String(); } } }

Array. List using System; using System. Collections. Generic; using System. Text; using System. Collections;

Array. List using System; using System. Collections. Generic; using System. Text; using System. Collections; namespace arraylistornek { class Program { static void Main(string[] args) { Array. List liste = new Array. List(); int[] sayilar ={ 3, 4, 6, 23, 5, 13 }; liste. Add(89); liste. Add(19); foreach (int i in liste) Console. Write(i + " "); Console. Write. Line(""); liste. Add. Range(sayilar); // dizi ekle liste. Sort(); // sirala foreach (int i in liste) Console. Write(i + " "); Console. Write. Line(""); liste. Insert(1, 15); // birinci eleman olarak 15 ekle foreach (int i in liste) Console. Write(i + " "); Console. Write. Line(""); liste. Remove(3); // 3 sayisini sil foreach (int i in liste) Console. Write(i + " "); Console. Write. Line(""); liste. Clear(); //listeyi temizle } } }

Array List-2 namespace array { public partial class Form 1 : Form { public

Array List-2 namespace array { public partial class Form 1 : Form { public Form 1() { Initialize. Component(); } private void button 1_Click(object sender, Event. Args e) { int toplam = 0; int[] sayilar = new int[5]; for (int i = 0; i < 5; i++) { sayilar[i] = i * 2; } for (int i = 0; i < 5; i++) { toplam = toplam + sayilar[i]; } Message. Box. Show("toplam =" + toplam); Array. List liste = new Array. List(); liste. Add(0); liste. Add(2); liste. Add(7); liste. Add(12); liste. Add(22); toplam = 0; foreach (int k in liste) { toplam = toplam + k; } Message. Box. Show("arraylist toplam =" + toplam); } }

Grafik-1 using System; using System. Collections. Generic; using System. Component. Model; using System. Data;

Grafik-1 using System; using System. Collections. Generic; using System. Component. Model; using System. Data; using System. Drawing; using System. Text; using System. Windows. Forms; namespace grafik { public partial class Form 1 : Form { public Form 1() { Initialize. Component(); } private void button 1_Click(object sender, Event. Args e) { Graphics g = this. Create. Graphics(); Pen kalem = new Pen(Color. Red, 3. 7 f); // Brush firca = new Brushes(Color. Red); g. Draw. Line(kalem, 30, 150); g. Draw. Pie(kalem, 50, 80, 0, 250); g. Draw. Ellipse(kalem, 150, 200); } } }

// Combobox ile şekil çizme using System; using System. Drawing; using System. Windows. Forms;

// Combobox ile şekil çizme using System; using System. Drawing; using System. Windows. Forms; Grafik-2 { case 0: // Daire çiz my. Graphics. Draw. Ellipse( my. Pen, 50, 150 ); break; case 1: // Dikdörtgen Çiz my. Graphics. Draw. Rectangle( my. Pen, 50, 150 ); break; case 2: // Elips Çiz my. Graphics. Draw. Ellipse( my. Pen, 50, 85, 150, 115 ); break; case 3: // Pie çiz my. Graphics. Draw. Pie( my. Pen, 50, 150, 0, 45 ); break; case 4: // içi dolu daire çiz my. Graphics. Fill. Ellipse( my. Solid. Brush, 50, 150 ); break; case 5: // içi dolu dikdörtgen çiz my. Graphics. Fill. Rectangle( my. Solid. Brush, 50, 150 ); break; case 6: // içi dolu elips çiz my. Graphics. Fill. Ellipse( my. Solid. Brush, 50, 85, 150, 115 ); break; case 7: // içi dolu pie çiz my. Graphics. Fill. Pie( my. Solid. Brush, 50, 150, 0, 45 ); break; } // end switch public partial class Combo. Box. Test. Form : Form { public Combo. Box. Test. Form() { Initialize. Component(); } // seçilen seçeneğe göre şekil seçilir private void image. Combo. Box_Selected. Index. Changed( object sender, Event. Args e ) { // Graphics objesi yarat Graphics my. Graphics = base. Create. Graphics(); // Dark. Red(koyu kırmızı) renkli Pen (kalem) yarat Pen my. Pen = new Pen( Color. Dark. Red ); // Dark. Red(koyu kırmızı) renkli Solid. Brush(fırça) yarat Solid. Brush my. Solid. Brush = new Solid. Brush( Color. Dark. Red ); // white(beyaz) renk ile grafik alanını temizle my. Graphics. Clear( Color. White ); // seçilen index sırasına göre şekil çiz switch ( image. Combo. Box. Selected. Index ) my. Graphics. Dispose(); // Graphics object yok et. } }

Grafik-3 using System; using System. Collections. Generic; using System. Component. Model; using System. Data;

Grafik-3 using System; using System. Collections. Generic; using System. Component. Model; using System. Data; using System. Drawing; using System. Text; using System. Windows. Forms; namespace Windows. Applicationgrfx 1 { public partial class Form 1 : Form { public Form 1() { Initialize. Component(); } private void button 1_Click(object sender, Event. Args e) { //create a unit pen. Pen p = new Pen(Color. Black, 1. 0 f); Graphics g = this. Create. Graphics(); 120); } } } g. Draw. Rectangle(Pens. Blue, 55, 40, 100, g. Draw. Rectangle(p, 20, 30); g. Draw. Line(Pens. Red, 0, 0, 100); g. Draw. Arc(p, 30, 0, 360);

Kronometre-timer namespace kronometre { public partial class Form 1 : Form { int kalansure

Kronometre-timer namespace kronometre { public partial class Form 1 : Form { int kalansure = 50; int sure = 50; bool durduldumu = false; int durdurmasuresi = 0; public Form 1() { Initialize. Component(); } private void Form 1_Load(object sender, Event. Args e) { text. Box 1. Text = "50"; } private void button 1_Click(object sender, Event. Args e) { timer 1. Interval = sure*10; durdurmasuresi = 0; kalansure = sure; durduldumu = false; timer 1. Start(); }

Kronometre-devam private void timer 1_Tick(object sender, Event. Args e) { if (kalansure > 0)

Kronometre-devam private void timer 1_Tick(object sender, Event. Args e) { if (kalansure > 0) { kalansure = kalansure - 1; text. Box 1. Text = kalansure. To. String(); } else { timer 1. Stop(); list. Box 1. Items. Add("süre doldu" ); Message. Box. Show("timer süresi doldu"); if (durdurmasuresi != kalansure) { durdurmasuresi = kalansure; list. Box 1. Items. Add("kronometre durduruldu" + kalansure. To. String()); timer 1. Stop(); } } private void button 3_Click(object sender, Event. Args e) { timer 1. Start(); durduldumu = false; } } private void button 2_Click(object sender, Event. Args e) { } } }

Ideal Kilo programi using System; using System. Collections. Generic; using System. Component. Model; using

Ideal Kilo programi using System; using System. Collections. Generic; using System. Component. Model; using System. Data; using System. Drawing; using System. Text; using System. Windows. Forms; namespace idealkilo { public partial class Form 1 : Form { public Form 1() { Initialize. Component(); } private void button 1_Click(object sender, Event. Args e) { double boy, kilo, katsayi, ideal, yas; boy = System. Double. Parse(text. Box 1. Text); kilo = System. Double. Parse(text. Box 2. Text); yas = System. Double. Parse(text. Box 3. Text); if (radio. Button 1. Checked == true) katsayi =0. 8; else katsayi = 0. 9; ideal = (boy - 100) + (yas / 10) * katsayi; if (kilo > ideal) Message. Box. Show("Sismanladın"); else if (kilo < ideal) Message. Box. Show("Zayifladin"); else Message. Box. Show("Supersin"); } } }

Parametreleri Konsolo Yazma using System; using System. Collections. Generic; using System. Text; namespace ornek

Parametreleri Konsolo Yazma using System; using System. Collections. Generic; using System. Text; namespace ornek 2 { class Program { static void Main(string[] args) { int sayi 1; Console. Write. Line("Bir sayi giriniz: "); sayi 1 = int. Parse(Console. Read. Line()); for (int i = 0; i < sayi 1; i++) { Console. Write. Line(" {0} dongu, tamami {1}", i, sayi 1); Console. Write. Line(i + "dongu" + "tamami" + sayi 1); } }

Şifre Bulma using System; using System. Collections. Generic; using System. Text; namespace ornek 4

Şifre Bulma using System; using System. Collections. Generic; using System. Text; namespace ornek 4 { class Program { static void Main(string[] args) { string tahmin, sifre; sifre ="56789"; do { Console. Write. Line("Sifre yi Girin: "); tahmin = Console. Read. Line(); } while( tahmin != sifre); Console. Write. Line(""); Console. Write. Line ("tebrikler sifreyi buldunuz"); } } }

Pizza Sipariş namespace pizza { public partial class Form 1 : Form { double

Pizza Sipariş namespace pizza { public partial class Form 1 : Form { double ucret, kolaucret; int adet; public Form 1() { Initialize. Component(); } private void button 1_Click(object sender, Event. Args e) { if (radio. Button 1. Checked) ucret = 5. 0; else if (radio. Button 2. Checked) ucret = 15. 00; else ucret = 10. 00; adet = int. Parse(text. Box 2. Text); kolaucret = adet * 1. 5; ucret = ucret + kolaucret; text. Box 1. Text = ucret. To. String(); } } }

Sayı Bulma Oyunu namespace sayitahmin { public partial class Form 1 : Form {

Sayı Bulma Oyunu namespace sayitahmin { public partial class Form 1 : Form { int sayi, tahminhakki=5; public Form 1() { Initialize. Component(); } private void button 1_Click(object sender, Event. Args e) { tahmin = int. Parse(text. Box 1. Text); tahminhakki--; if (tahminhakki > 0) if (sayi == tahmin) Message. Box. Show("Doðru tahmin"); else Message. Box. Show("hatalý tahmin"); else Message. Box. Show("tahmin hakký doldu"); } private void Form 1_Load(object sender, Event. Args e) { Random rasgele = new Random(); sayi = rasgele. Next(20); } } }

Sayı Bulma Oyunu Konsol using System; using System. Collections. Generic; using System. Text; namespace

Sayı Bulma Oyunu Konsol using System; using System. Collections. Generic; using System. Text; namespace sayioyunu { class Program { static void Main(string[] args) { int hak = 5; int tahmin = 1; int hedef = 120; int sayi; while (tahmin < 6) { Console. Write. Line("sayi giriniz : "); sayi = Convert. To. Int 16(Console. Read. Line()); if (sayi == hedef) { Console. Write. Line("sayi bulundu, tebrikler"); break; } else { tahmin = tahmin + 1; Console. Write. Line("bulamadýnýz, bir daha deneyin"); } } if (tahmin > 5) Console. Write. Line("hakkýnýz bitti, bulamasýnýz, game over"); } } }

Otobüs Bilet uygulaması using System; using System. Collections. Generic; using System. Component. Model; using

Otobüs Bilet uygulaması using System; using System. Collections. Generic; using System. Component. Model; using System. Data; using System. Drawing; using System. Text; using System. Windows. Forms; namespace gezi { public partial class Form 1 : Form { // Genel deðiþkenler ve ilk atama deyimleri int bosyer = 30; int toplananpara = 0; public Form 1() { Initialize. Component(); } private void text. Box 3_Text. Changed(object sender, Event. Args e) { } private void radio. Button 1_Checked. Changed(object sender, Event. Args e) { }

private void button 1_Click(object sender, Event. Args e) { if (bosyer > 0) {

private void button 1_Click(object sender, Event. Args e) { if (bosyer > 0) { if (radio. Button 1. Checked == true) { list. Box 1. Items. Add(text. Box 1. Text + " Çocuk"); toplananpara = toplananpara + 10; } else { list. Box 1. Items. Add(text. Box 1. Text + " Büyük"); toplananpara = toplananpara + 25; } private void Form 1_Load(object sender, Event. Args e) { // ilk atamalar burada da yapýlabilir text. Box 2. Text = "30"; text. Box 3. Text = "0"; } 0)) private void button 2_Click(object sender, Event. Args e) { if ((list. Box 1. Items. Count > 0) && (list. Box 1. Selected. Index >= { bosyer = bosyer - 1; text. Box 2. Text = bosyer. To. String(); text. Box 3. Text = toplananpara. To. String(); } else Message. Box. Show("Otobüs boþyer kalmadý"); text. Box 2. Text = bosyer. To. String(); text. Box 3. Text = toplananpara. To. String(); } else Message. Box. Show("listboxda kiþi seçiniz"); } private void label 1_Click(object sender, Event. Args e) { } list. Box 1. Items. Remove(list. Box 1. Text); bosyer = bosyer + 1; if (radio. Button 1. Checked == true) toplananpara = toplananpara - 10; else toplananpara = toplananpara - 25; } } }