Beispiel #1
0
        public void GenerateName(NamesD nameD)
        {
            int generated;
            Random namerand = new Random();
            char[] Temp_Firstname = new char[4];
            char[] Temp_Lastname = new char[6];

            for (int u = 0; u != 10000; u++)
            {
                for (int i = 0; i != 4; i++)
                {
                    generated = namerand.Next(0, 25);
                    Temp_Firstname[i] = letters[generated];
                }
                for (int i = 0; i != 6; i++)
                {
                    generated = namerand.Next(0, 25);
                    Temp_Lastname[i] = letters[generated];
                }
                Firstname = new string(Temp_Firstname);
                Lastname = new string(Temp_Lastname);
                NameD fullname = new NameD { Firstname = new string(Temp_Firstname), Lastname = new string(Temp_Lastname) };
                nameD.Addname(fullname, u);
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            // Creating Stopwatch object timer
            Stopwatch timer = new Stopwatch();

            // Creating objects for the List testing
            Names allnames = new Names();
            Name name = new Name();
            timer.Start();
            name.GenerateName(allnames); // Generating 10 000 names and adding them to list
            allnames.ShowNames(); // Printing out the names
            Console.WriteLine(timer.ElapsedMilliseconds);
            timer.Stop();
            timer.Reset();


            NameD nameD = new NameD();
            NamesD namesD = new NamesD();
            timer.Start();
            nameD.GenerateName(namesD);
            namesD.ShowNames();
            Console.WriteLine(timer.ElapsedMilliseconds);
            timer.Stop();

        }