示例#1
0
        public static Stud[] LoadFile()
        {
            string[] lines  = null;
            Stud[]   result = null;
            if (filename != null)
            {
                lines = System.IO.File.ReadAllLines(filename);


                result = new Stud[lines.Length];

                for (int i = 0; i < lines.Length; i++)
                {
                    result[i] = ParseLine(lines[i]);
                }
            }
            return(result);
        }
示例#2
0
        public static Stud ParseLine(string line)
        {
            Stud result = null;

            string[] subs = line.Split('\t');
            if (subs.Length == 4)
            {
                result = new Enrolle(subs[0], DateTime.Parse(subs[1]), subs[2], int.Parse(subs[3]));
            }
            else
            {
                if (subs.Length == 5)
                {
                    result = new Teatcher(subs[0], DateTime.Parse(subs[1]), subs[2], subs[3], int.Parse(subs[4]));
                }
                else
                {
                    throw new FormatException("База поврежденна");
                }
            }

            return(result);
        }