using System;
class BoxingProgram
{
public static void Main()
{
int i = 20;
//
object obj = i;
// Boxing copies the value of i into object obj and its a implicit process
// If I Change the value of i.
i = 50;
// The change in i does not effect the value stored in obj.
Console.WriteLine("The value type value = {0}", i);
Console.WriteLine("The object type value = {0}", obj);
}
}
/* Output:
The value type value = 50
The object type value = 20
*/
class BoxingProgram
{
public static void Main()
{
int i = 20;
//
object obj = i;
// Boxing copies the value of i into object obj and its a implicit process
// If I Change the value of i.
i = 50;
// The change in i does not effect the value stored in obj.
Console.WriteLine("The value type value = {0}", i);
Console.WriteLine("The object type value = {0}", obj);
}
}
/* Output:
The value type value = 50
The object type value = 20
*/
No comments:
Post a Comment