Пример #1
0
        public void DeleterEvenOfFile()
        {
            FileWork ClassPut = new FileWork(Arr);

            string[] ArrFile = ClassPut.ReadArrayFromBinaryFile(Arr);
            for (int i = 0; i < ArrFile.Length; i++)
            {
                if (Convert.ToInt32(ArrFile[i]) % 2 == 0)
                {
                    ArrFile[i] = "";
                }
            }
            string str = "";

            for (int i = 0; i < ArrFile.Length; i++)
            {
                str += ArrFile[i] + Environment.NewLine;
            }
            ClassPut.WriteArrayToBinaryFile(str);
        }
Пример #2
0
        public string SearchFive()
        {
            FileWork ClassPut = new FileWork(Name);

            string[] ArrFile = ClassPut.ReadAndConvertToArr();
            students = new List <Student>();
            char delimiter = ' ';

            for (int j = 0; j < ArrFile.Length; j++)
            {
                string[] arr = ArrFile[j].Split(delimiter);
                string   Name, Date, Year, Group;
                Name = arr[0] + ' ' + arr[1] + ' ' + arr[2];
                Date = arr[3];
                double MedM;
                if (!(Double.TryParse(arr[4], out MedM)))
                {
                    return("Файл не может быть создан");
                }
                Year  = arr[5];
                Group = arr[6];
                students.Add(new Student(Name, Date, MedM, Year, Group));
            }

            int[]  index = SearchMax(students);
            string str   = "";

            for (int j = 0; j < 5; j++)
            {
                str += students[index[j]].Name + ' ' + students[index[j]].Date + ' '
                       + students[index[j]].MedM + ' ' + students[index[j]].Year + ' '
                       + students[index[j]].Group + Environment.NewLine;
            }

            int    i   = Name.LastIndexOf('.');
            string New = Name.Substring(0, i) + "(better)" + Name.Substring(i);

            ClassPut.CreateStudents(str, New);
            return(New);
        }