블로그 이미지
Sunny's

calendar

1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

Notice

2009. 5. 11. 18:58 .NET Framework
 상속 관계...


받는 쪽 구현

 using System;
 using System.Collections;
 public class SamplesQueue  {

    public static void Main()  {

       // Creates and initializes a new Queue.
       Queue myQ = new Queue();
       myQ.Enqueue("Hello");
       myQ.Enqueue("World");
       myQ.Enqueue("!");

       // Displays the properties and values of the Queue.
       Console.WriteLine( "myQ" );
       Console.WriteLine( "\tCount:    {0}", myQ.Count );
       Console.Write( "\tValues:" );
       PrintValues( myQ );
    }


    public static void PrintValues( IEnumerable myCollection )  {
       foreach ( Object obj in myCollection )
          Console.Write( "    {0}", obj );
       Console.WriteLine();
    }
 }
 /* 
 This code produces the following output.

 myQ
     Count:    3
     Values:    Hello    World    !
*/ 
 

테스트 코드

 

namespace Queue_Test
{
    public class Queue_Control_Class
    {
        protected void QueueControl(ref IEnumerable tempQueue)
        {
            Queue testQueue = (Queue)tempQueue;

            if (testQueue.Count != 0)
            {
                testQueue.Dequeue();
            }
        }
    }

    public class Queue_Save_Class : Queue_Control_Class
    {
        public Queue _SaveQueue = new Queue();

        public void QueueDeQueue()
        {
            IEnumerable tempQueue = _SaveQueue;

            QueueControl(ref tempQueue);
        }
           
    }

    class Program
    {
        static void Main(string[] args)
        {
            Queue_Save_Class test = new Queue_Save_Class();
            for(int i=0; i<5; i++)
                test._SaveQueue.Enqueue(i);
            foreach (int temp in test._SaveQueue)
            {
                Console.Write("{0} ", temp);
            }
            Console.WriteLine("");
            test.QueueDeQueue();
            foreach (int temp in test._SaveQueue)
            {
                Console.Write("{0} ", temp);
            }
            Console.ReadKey();
        }
    }
}




 

posted by Sunny's
prev 1 next