Boxing and Unboxing
来源:互联网 发布:linux 卡片电脑 编辑:程序博客网 时间:2024/05/01 20:33
using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
namespace Boxing
{
class Program
{
static void Main(string[] args)
{
int count;
DateTime startTime = DateTime.Now;
ArrayList AyList = new ArrayList();
// 重复5次测试
for (int i = 5; i > 0; i--)
{
AyList.Clear();
// 将值类型加入myArrayList数组
for (count = 0; count < 5000; count++)
{
Console.WriteLine("开始Boxing.....");
//Boxing
AyList.Add(count);
}
// 重新得到值
int j;
for (count = 0; count < 5000; count++)
{
Console.WriteLine("开始Unboxing....");
//Unboxing
j = (int)AyList[count];
}
}
// 打印结果
DateTime endTime = DateTime.Now;
Console.WriteLine("开始时间: {0} 结束时间: {1} 耗时: {2}", startTime, endTime, endTime - startTime);
Console.WriteLine("按回车结束程序...");
}
}
}
using System.Collections.Generic;
using System.Collections;
using System.Text;
namespace Boxing
{
class Program
{
static void Main(string[] args)
{
int count;
DateTime startTime = DateTime.Now;
ArrayList AyList = new ArrayList();
// 重复5次测试
for (int i = 5; i > 0; i--)
{
AyList.Clear();
// 将值类型加入myArrayList数组
for (count = 0; count < 5000; count++)
{
Console.WriteLine("开始Boxing.....");
//Boxing
AyList.Add(count);
}
// 重新得到值
int j;
for (count = 0; count < 5000; count++)
{
Console.WriteLine("开始Unboxing....");
//Unboxing
j = (int)AyList[count];
}
}
// 打印结果
DateTime endTime = DateTime.Now;
Console.WriteLine("开始时间: {0} 结束时间: {1} 耗时: {2}", startTime, endTime, endTime - startTime);
Console.WriteLine("按回车结束程序...");
}
}
}
- 11.3 Boxing and unboxing
- Boxing and Unboxing
- Boxing and Unboxing
- Boxing and Unboxing
- BOXING AND UNBOXING FOR BEGINNER
- Boxing and unboxing in C#
- boxing, unboxing
- Java Auto Boxing and Unboxing -Java 学习笔记 (23)
- CLR 是怎样去处理Boxing and Unboxing Value Types?
- Effective C#之17:Minimize Boxing and Unboxing.
- 关于Boxing和Unboxing
- 关于boxing 和 unboxing
- C#的Boxing/Unboxing解析
- java中的Boxing和unboxing
- java中的auto-boxing/unboxing
- 6 important .NET concepts: - Stack, heap, Value types, reference types, boxing and Unboxing.
- C#中装箱和拆箱的作用 the effection of boxing and unboxing
- C#中的"装箱"(boxing)与"拆箱"(unboxing)
- 关于读写配置文件MBean实现结构的调整
- oracle 10.2g在CentOS 5.1和redhat 5企业版上的安装过程
- Microsoft JET Database Engine (0x80040E09) 不能更新。数据库或对象为只读。
- 谁帮我写个小程序呀
- 卡尔曼滤波
- Boxing and Unboxing
- 盗版软件的受害者
- [转]关于ABAP的介绍
- 监控屏幕图像的技术实现
- 习惯成自然
- 地震有感
- 基于主题的蜘蛛搜索技术
- 用户体验测试的自动化实现 - 对检查Tab顺序的脚本进行完善
- 10个不为人知的Google失败作品(图文)