예제 #1
0
        public List <ReadData> ReadData()
        {
            list.Clear();
            //if(File.Exists("data.txt"))
            read = new StreamReader("data.txt");
            String line;

            while ((line = read.ReadLine()) != null)
            {
                ReadData user = new ReadData();
                string   n    = line.Trim();
                user.SetID(line.Trim());

                line = read.ReadLine();
                string n1 = line.Trim();
                user.SetName(n1);

                line = read.ReadLine();
                string n2 = line.Trim();
                user.SetSemester(n2);

                line = read.ReadLine();
                string n3 = line.Trim();
                user.SetCGPA(n3);

                line = read.ReadLine();
                string n4 = line.Trim();
                user.SetDepartment(n4);

                line = read.ReadLine();
                string n5 = line.Trim();
                user.SetCampus(n5);

                read.ReadLine();
                list.Add(user);
            }
            read.Close();
            confirmList.Clear();
            confirmList = list.Distinct().ToList();
            return(confirmList);
        }
예제 #2
0
        //private Stream()
        //{
        //    write = new StreamWriter("data.txt"); write.Close();
        //    read = new StreamReader("data.txt"); // abhi create krni hai ye file
        //    read.Close();
        //}
        public List <ReadData> ReadData()
        {
            read = new StreamReader("data.txt");
            String          line;
            List <ReadData> list = new List <ReadData>();

            while ((line = read.ReadLine()) != null)
            {
                ReadData user = new ReadData();
                string   n    = line.Trim();
                user.SetID(line.Trim());

                line = read.ReadLine();
                string n1 = line.Trim();
                user.SetName(n1);

                line = read.ReadLine();
                string n2 = line.Trim();
                user.SetSemester(n2);

                line = read.ReadLine();
                string n3 = line.Trim();
                user.SetCGPA(n3);

                line = read.ReadLine();
                string n4 = line.Trim();
                user.SetDepartment(n4);

                line = read.ReadLine();
                string n5 = line.Trim();
                user.SetCampus(n5);

                read.ReadLine();
                list.Add(user);
            }
            read.Close();
            return(list);
        }