- Katılım
- 14 Ağustos 2008
- Mesajlar
- 12,189
- Reaksiyon puanı
- 104
- Puanları
- 3,243
iki bağlı dairesel listede;
sinif.cs
form.cs
dumplist fonksiyonuna gönderirken liste sıfırlanıyor ve listbox'a veri yazamıyorum. Acaba sorun nedir. Bugün sınavım kötü geçti büte kalmamak için bu projeyi yapmam lazım.
Şu listbox'a sorunsuz veriyi göndersem gersini getireceğim. 
sinif.cs
Kod:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace mgProje
{
public class sinif
{
public int no, tc;
public string isim, eposta, adres, sehir, bolum, snf, tel,dtarih;
public sinif flink;
public sinif blink;
}
}
form.cs
Kod:
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.IO;
namespace mgProje
{
public partial class Form1 : Form
{
sinif l1=null;
public sinif newnode()
{
sinif newsinif = new sinif();
newsinif.flink = newsinif;
newsinif.blink = newsinif;
return(newsinif);
}
public sinif cons(int c_no,string c_isim,int c_tc,string c_sehir,string d_tarih,string c_bolum,string c_sube,string c_eposta,string c_cep,string c_adres)
{
sinif cons_;
cons_ = newnode();
cons_.no = c_no;
cons_.isim = c_isim;
cons_.tc = c_tc;
cons_.sehir = c_sehir;
cons_.dtarih = d_tarih;
cons_.bolum = c_bolum;
cons_.snf = c_sube;
cons_.eposta = c_eposta;
cons_.tel = c_cep;
cons_.adres = c_adres;
return (cons_);
}
public sinif last(sinif list)
{
sinif ylist = list;
if (list != null)
{
if (list.flink == list)
{
return (list);
}
else
{
do
{
list = list.flink;
} while (list.flink != ylist);
}
}
return list;
}
sinif addlast(sinif node_,sinif list)
{
if(list==null){
list = node_;
return list;
}
else{
node_.flink = last(list).flink;
node_.blink = last(list);
last(list).flink = node_;
list.blink = node_;
}
return list;
}
public void dumplist(sinif list)
{
int i = 1;
sinif ylist = list;
string s;
if (list != null)
{
do
{
s = (list.no).ToString() + " " + list.isim + " " + (list.tc).ToString() + " " + list.sehir + " " + list.dtarih + " " + list.bolum + " " + list.snf + " " + " " + list.eposta + " " + list.tel + " " + list.adres;
listBox1.Items.Add(s);
list = list.flink;
i++;
} while (list != ylist);
}
}
public Form1()
{
InitializeComponent();
}
int xno, xtc;
string xisim, xsehir, xd_tarih, xbolum, xsube, xeposta, xtel,xadres;
private void Form1_Load(object sender, EventArgs e)
{
StreamReader oku = File.OpenText("c:\\ogrenci.txt");
//string s;
//do
//{
// s = oku.ReadLine();
// listBox1.Items.Add(s);
//} while (s != null);
string str = oku.ReadLine();
//listBox1.Items.Add(str);
string[] dizi = str.Split(' ');
xno = Convert.ToInt32(dizi[0]);
xisim = dizi[1];
xtc = Convert.ToInt32(dizi[2]);
xsehir = dizi[3];
xd_tarih = dizi[4];
xbolum = dizi[5];
xsube = dizi[6];
xeposta = dizi[7];
xtel = dizi[8];
xadres = dizi[9];
addlast(cons(xno, xisim, xtc, xsehir, xd_tarih, xbolum, xsube, xeposta, xtel, xadres), l1);
dumplist(l1);
}
}
}
dumplist fonksiyonuna gönderirken liste sıfırlanıyor ve listbox'a veri yazamıyorum. Acaba sorun nedir. Bugün sınavım kötü geçti büte kalmamak için bu projeyi yapmam lazım.

