Пример #1
0
        static void Main(string[] args)
        {
            CitireFisier("input.txt");

            Angajat.ListaAngajatilorAlfabetic();

            Console.WriteLine();

            Angajat.ListaAngajatilorDataAngajarii();
        }
Пример #2
0
        private static void CitireFisier(string v)
        {
            char[] cifre = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
            try
            {
                using (StreamReader read = new StreamReader(v))
                {
                    string line;
                    int    pozitieSfarsitNume = 0;
                    int    pozitieInceputData = 0;
                    bool   lineParcursa       = false;

                    while ((line = read.ReadLine()) != null)
                    {
                        for (int i = 0; i < line.Length; i++)
                        {
                            if (!lineParcursa)
                            {
                                if (line[i] == ' ')
                                {
                                    for (int j = 0; j < cifre.Length; j++)
                                    {
                                        if (line[i + 1] == cifre[j])
                                        {
                                            pozitieSfarsitNume = i;
                                            pozitieInceputData = i + 1;
                                            var angajat = new Angajat(AdaugareNume(pozitieSfarsitNume, line),
                                                                      AdaugareData(pozitieInceputData, line));
                                            lineParcursa = true;
                                            break;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                }
            }
            catch (FileNotFoundException e)
            {
                File.Create(e.FileName);
            }
        }