摘要:
using System;namespace exercise { class Program { static unsafe void Main(string[] args) { //创建基于栈的数组 decimal* pDecimals = stackalloc decimal[10]; int size; size = 20; //or some other value calculated at runtime double* pDoubles = stac... 阅读全文
posted @ 2013-01-10 10:52
nil
阅读(151)
评论(0)
推荐(0)
摘要:
using System;namespace exercise { class Program { static unsafe void Main(string[] args) { //PointerPlayground2 该示例介绍指针的算术,以及结构指针和类成员指针。开始时,定义一个结构CurrencyStruct, //它把货币值表示为美元和美分,再定义一个等价的类CurrencyClass: //查看存储在栈中的项的地址 Console.WriteLine("Szie of Cu... 阅读全文
posted @ 2013-01-10 10:35
nil
阅读(130)
评论(1)
推荐(0)
摘要:
引用类型的分配相当复杂,该博文只说明这两种实例化的区别。static void Main(string[] args) { Customer customer1; customer1 = new Customer();} Customer customer1; 声明一个 Customer引用customer1,会在栈上给这个引用分配存储空间。但这只是一个引用,而不是实际的Customer对象,customer1引用占用4个字节的空间(GetHashCode()返回的是一个int类型)。 customer1 = new Customer(); 这行代码完成了以下操作:首先... 阅读全文
posted @ 2013-01-08 17:31
nil
阅读(835)
评论(2)
推荐(0)
摘要:
在C#中,声明 两个int类型的变量 i 和 j ,有两种声明方式:static void Main(string[] args) { int i; int j;}static void Main(string[] args) { int i, j;} 今天在看《C#高级编程》时,看到了他们的区别,记录下来。 PS:i和j在同一作用域中。 int类型属于值类型,而值类型是存储在栈中的,栈的数据存储属于后进先出(last-in, first-out, LIFO)类型。 对于第一种声明方式,栈指针会先为变量 i 分配空间,再为 j 分配空间,回收空间的时候会先回收 j... 阅读全文
posted @ 2013-01-08 16:25
nil
阅读(826)
评论(3)
推荐(0)
摘要:
Linq 延迟查询 阅读全文
posted @ 2013-01-07 12:21
nil
阅读(205)
评论(1)
推荐(0)
浙公网安备 33010602011771号