一、托管资源和非托管资源
托管 --->垃圾回收(GC)机制
非托管-->文件句柄,网络连接,数据库连接等。解决办法:实现System.IDisposable接口
这里列举几种常见的非托管资源:ApplicationContext,Brush,Component,ComponentDesigner,Container,Context,Cursor,FileStream,Font,Icon,Image,Matrix,Object,OdbcDataReader,OleDBDataReader,Pen,Regex,Socket,StreamWriter,Timer,Tooltip
二、值类型与引用类型
栈-----值类型
(托管堆) 堆------引用类型
1.值类型
在处理器的虚拟内存中,有一个区域称为栈,栈存储值类型数据。当变量超出作用域时,会释放变量。
2.引用类型
堆是处理器的可用内存的另一个内存区域,看看下面的代码:
void{
Customer arabel;
arabel=new Customer();
Customer otherCustomer=new EnhancedCustomer();
}
在这段代码中,有两个类Customer和EnhancedCustomer。EnchhancedCustomer类扩
1555



被折叠的 条评论
为什么被折叠?



