Put user-defined objects to Queue collection : Queue : Collections Data Structure C# Source Code


Custom Search

C# Source Code » Collections Data Structure » Queue »

 

Put user-defined objects to Queue collection








    
 

using System;
using System.Collections;

public class Starter {
    public static void Main() {
        Queue waiting = new Queue();
        waiting.Enqueue(new Customer("B"));
        waiting.Enqueue(new Customer("T"));
        waiting.Enqueue(new Customer("K"));
        waiting.Enqueue(new Customer("S"));

        while (waiting.Count != 0) {
            Customer cust =
                (Customer)waiting.Dequeue();
            Console.WriteLine(cust.Name);
        }
    }

    public class Customer {
        public Customer(string cName) {
            propName = cName;
        }

        private string propName;
        public string Name {
            get {
                return propName;
            }
        }
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Collections Data Structure
» Queue