帖一个封箱的简单例子!
using System;
namespace Boxing装箱
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class Test
{
[STAThread]
public static void Main()
{
int i=10;
object obj=i;
if(obj is int)
{
Console.Write("The value of i is boxing!");
}
i=20;
Console.WriteLine("int:i={0}",i);
Console.WriteLine("object:obj={0}",obj);
}
}
}
封箱的例子比较少,共勉一下!