22-İki Boyutlu Dizi Örneği : Bölgeler Şehirler
namespace ikiBoyutluDizi_
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string[,] bolgeler = new string[7, 3]{
{"İZMİR","AYDIN","MANİSA"},
{"İSTANBUL","İZMİT","BURSA"},
{"TRABZON","ORDU","RİZE"},
{"VAN","KARS","ERZURUM"},
{"HAKKARİ","MARDİN","ŞIRNAK"},
{"ADANA","ANTALYA","MERSİN"},
{"KONYA","ANKARA","NEVŞEHİR"}
};
string[] bolge_isimleri = { "EGE BÖLGESİ", "MARMARA", "KARADENİZ", "DOĞU ANADOLU", "GÜNEYDOĞU", "AKDENİZ", "İÇ ANADOLU" };
private void button1_Click(object sender, EventArgs e)
{
//MessageBox.Show(bolgeler[3, 2]);
for (int i = 0; i < bolgeler.GetUpperBound(0); i++)//tek boyutlu dizide GetUpperBound yerine Length yazıyorduk.
{
listBox1.Items.Add(bolge_isimleri[i]);
for (int j = 0; j < bolgeler.GetUpperBound(1); j++)
{
listBox1.Items.Add(bolgeler[i, j]);
}
listBox1.Items.Add("------------");
}
}
}
}

Yorumlar
Yorum Gönder