static void Main(string[] args)
    {
        //Generic type instantiation using reference type
        OrderContainer <OrderObj> orderObjContainer = new OrderContainer <OrderObj>(10);

        //Add and retrieve reference type order
        orderObjContainer.AddOrder(new OrderObj());
        OrderObj orderObj = orderObjContainer.GetOrder(0);

        //Generic type instantiation using value type
        OrderContainer <OrderStruct> orderStructContainer = new OrderContainer <OrderStruct>(10);

        //Add and retrieve value type order
        orderStructContainer.AddOrder(new OrderStruct());
        OrderStruct orderStruct = orderStructContainer.GetOrder(0);
    }
Beispiel #2
0
    static void Main(string[] args)
    {
        //create order container to store reference type orders
        OrderContainer orderObjContainer = new OrderContainer(10);

        //Adding orders of reference type
        orderObjContainer.AddOrder(new OrderObj());
        //Cast Operation
        OrderObj orderObj = orderObjContainer.GetOrder(0) as OrderObj;

        //create order container to store value type orders
        OrderContainer orderStructContainer = new OrderContainer(10);

        //Adding orders of value type
        //Boxing Cost
        orderStructContainer.AddOrder(new OrderStruct());
        //Unboxing Cost
        object orderStruct = orderStructContainer.GetOrder(0);
    }