Box to object : Boxing Unboxing « Data Types « C# / C Sharp






Box to object

 

class MyBoxingClass
{
    public static void DisplayMyCollection(params object[] anArray)
    {
        foreach (object obj in anArray)
        {
            System.Console.Write(obj + "\t");
        }

        // Suspend the screen.
        System.Console.ReadLine();
    } 

    static void Main()
    {
        DisplayMyCollection(101, "Visual C# Basics", 2002);
    }
}

   
  








Related examples in the same category

1.implicit boxing of an int
2.explicit boxing of an int to an object
3.explicit unboxing of an object to an int
4.A simple boxing/unboxing exampleA simple boxing/unboxing example
5.Boxing also occurs when passing valuesBoxing also occurs when passing values
6.Boxing makes it possible to call methods on a valueBoxing makes it possible to call methods on a value
7.Illustrates boxing and unboxingIllustrates boxing and unboxing
8.Automatic boxing and unboxing to pass an undetermined data type to a functionAutomatic boxing and unboxing to pass an undetermined data type to a function
9.is and Box UnBoxis and Box UnBox
10.Boxing struct object