예제 #1
0
        static void Main(string[] args)
        {
            string name;
            int month, day, year;
            int i;
            string phone;
            Friend myfriend = null;

            Friend[] friend;
            friend = new Friend[3];

            for(i = 0; i < friend.Length; i++)
            {
                GetData(out name, out month, out day, out year, out phone);

                friend[i] = new Friend(name, month, day, year, phone);
            }

            Array.Sort(friend);
            Console.WriteLine("Sorted List:");
            for (i = 0; i < friend.Length; i++)
            {
                Console.WriteLine(friend[i].name);
            }

            Console.Write("Enter a specific friend's name:");
                name = Console.ReadLine();

            for (i = 0; i < friend.Length; i++)
            {
                if (name == friend[i].name)
                {
                    myfriend = friend[i];
                }
            }

            if (myfriend != null)
            {
                Console.WriteLine("Phone: {0}, Birthday: {1}/{2}/{3}", myfriend.phone, myfriend.month, myfriend.day, myfriend.year);
                Console.WriteLine("Friends with the same birthday: ");
                for (i = 0; i < friend.Length; i++)
                {
                    if (myfriend.month== friend[i].month)
                    {
                        Console.WriteLine(friend[i].name);
                    }
                }

            }
        }