textbox’a girilen il’e göre Plaka Kodunu label’da gösterme C#

textbox’a girilen il’e göre Plaka Kodunu label’da gösterme C#

Not : using System.Collections isim uzayını eklemeyi unutmayın.

[code lang=”csharp”]

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.Collections;

namespace nesne_2.donem_2.uygulamaa

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

Hashtable tablo = new Hashtable();

string[] iller = { "Adana" ,"Adıyaman" ,"Afyon", "Ağrı", "Amasya" , "Ankara" ,"Antalya" , "Artvin","Aydın" , "Balıkesir", "Bilecik", "Bingöl" ,"Bitlis", "Bolu" };

string[] kodlar = { "01","02","03","04","05","06","07","08","09","10","11","12","13","14"};

private void Form1_Load(object sender, EventArgs e)

{

for (int i = 0; i < iller.Length; i++)

{

tablo.Add( iller[i],kodlar[i]);

}

}

private void btnBul_Click(object sender, EventArgs e)

{

Boolean durum = tablo.ContainsKey(textBox1.Text);

if (durum == true)

{

label1.Text = tablo[textBox1.Text].ToString();

}

else MessageBox.Show("Bulunamadı");

}

}

}

[/code]

Yorumlar 5

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir