Beispiel #1
0
        public static List <Ogrenci> Birlestir()
        {
            List <string> d1 = new List <string>();

            d1 = readTxt("d1.txt", d1);
            List <string> d2 = new List <string>();

            d2 = readTxt("d2.txt", d2);
            List <string> d3 = new List <string>();

            d3 = readTxt("d3.txt", d3);
            List <Ogrenci> ogrenciler = new List <Ogrenci>();

            foreach (var d1_rows in d1)
            {
                if (d1_rows != null)
                {
                    string[] splits  = d1_rows.Split('|');
                    Ogrenci  ogrenci = new Ogrenci();
                    ogrenci.numarasi = splits[0];
                    ogrenci.adi      = splits[1];
                    ogrenci.soyadi   = splits[2];
                    ogrenciler.Add(ogrenci);
                }
            }

            foreach (var d2_rows in d2)
            {
                if (d2_rows != null)
                {
                    string[] splits = d2_rows.Split('|');
                    foreach (var ogrenci in ogrenciler)
                    {
                        if (splits[0] == ogrenci.numarasi)
                        {
                            if (splits[1] != "")
                            {
                                ogrenci.vize = Convert.ToInt32(splits[1]);
                                break;
                            }
                        }
                    }
                }
            }

            foreach (var d3_rows in d3)
            {
                if (d3_rows != null)
                {
                    string[] splits = d3_rows.Split('|');
                    foreach (var ogrenci in ogrenciler)
                    {
                        if (splits[0] == ogrenci.numarasi)
                        {
                            if (splits[1] != "")
                            {
                                ogrenci.final = Convert.ToInt32(splits[1]);
                                break;
                            }
                        }
                    }
                }
            }

            foreach (var ogrenci in ogrenciler)
            {
                Console.WriteLine(ogrenci.numarasi + ", " +
                                  ogrenci.adi + " " +
                                  ogrenci.soyadi +
                                  " Vize: " + ogrenci.vize +
                                  " Final: " + ogrenci.final);
            }

            return(ogrenciler);
        }