コード例 #1
0
        private void Input()
        {
            Competitor competitor;
            string     name, department;

            //idNumber is the serial number of the reading
            int          idNumber     = 1;
            StreamReader streamReader = new StreamReader("competitors.txt");

            while (!streamReader.EndOfStream)
            {
                name       = streamReader.ReadLine();
                department = streamReader.ReadLine();
                competitor = new Competitor(idNumber, name, department);
                //The competitor is added to the list of the competitors.
                competitors.Add(competitor);
                idNumber++;
            }
            streamReader.Close();
        }
コード例 #2
0
ファイル: Controller.cs プロジェクト: MorrisMuuoMulitu/C-
        private void ReadData()
        {
            Competitor competitor;
            string     name, department;
            int        idNumber = 1;

            //read the data
            StreamReader reader = new StreamReader("competitors.txt");

            while (!reader.EndOfStream)
            {
                name       = reader.ReadLine();
                department = reader.ReadLine();

                //create an object
                competitor = new Competitor(idNumber, name, department);
                //add the new competitor object to list
                competitors.Add(competitor);

                idNumber++;
            }
            reader.Close();
        }