STRUCT_YAPI_OLUŞMAK
Structh ile listbox görüntüleme
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;
namespace struct_to_listbox
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
struct ogrenci
{
public int numara;
public string ad;
public string soyad;
public string sınıf;
}
ogrenci ogrenciler = new ogrenci();
private void btn_listele_Click_Click(object sender, EventArgs e)
{
listBox1.Items.Add(ogrenciler.ad);
listBox1.Items.Add(ogrenciler.soyad);
listBox1.Items.Add(ogrenciler.sınıf);
listBox1.Items.Add(ogrenciler.numara);
}
private void Form1_Load(object sender, EventArgs e)
{
ogrenciler.ad = "Barış";
ogrenciler.soyad = "BEKAR";
ogrenciler.numara = 625;
ogrenciler.sınıf = "12/b";
}
}
}
KODUMUZU ÇALIŞTIRDIGIMIZDA BUTTON'A TIKLANDIKTAN SONRAKİ HALİ ekran görüntüsü
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;
namespace struct_to_listbox
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
struct ogrenci
{
public int numara;
public string ad;
public string soyad;
public string sınıf;
}
ogrenci ogrenciler = new ogrenci();
private void btn_listele_Click_Click(object sender, EventArgs e)
{
listBox1.Items.Add(ogrenciler.ad);
listBox1.Items.Add(ogrenciler.soyad);
listBox1.Items.Add(ogrenciler.sınıf);
listBox1.Items.Add(ogrenciler.numara);
}
private void Form1_Load(object sender, EventArgs e)
{
ogrenciler.ad = "Barış";
ogrenciler.soyad = "BEKAR";
ogrenciler.numara = 625;
ogrenciler.sınıf = "12/b";
}
}
}
KODUMUZU ÇALIŞTIRDIGIMIZDA BUTTON'A TIKLANDIKTAN SONRAKİ HALİ ekran görüntüsü
Yorumlar
Yorum Gönder
Lütfen imla kurallarına göre karakterler kullanınız.