摘要: conn.execute(sql)(0) 不加(0)的用法: set rs=conn.execute(sql)'将这个结果赋给rs 这时要读取这个记录集第一个字段的数据就用rs(0) 输出是用<%Response.Write rs(0)%>或<%=rs(0)%> 加(0)表示不将这个结果赋给任何变量,直接显示 <%=conn.execute(sql)(0)%>显示第一个字段的内容 两种用法得到的结果是一样的, 加(0)对于只需读取一个字段时方便,而不加(0)主要针对读取的字段是多个的情况例如:conn.execute( "select id 阅读全文
posted @ 2011-07-30 00:10 winchou 阅读(272) 评论(0) 推荐(0) 编辑
摘要: .net内置了垃圾回收的机制,balabala一大堆 我就觉得微软很贴心,我们也没必要手动回收了...弱引用很好用,可以用一下//Person p1 = new Person(); //Person p2 = p1; //p1 = null; Person p1 = new Person(); //虽然wr弱引用,还是指向了Person对象,但是依然可以进行垃圾回收。 WeakReference wr = new WeakReference(p1);//弱引用。 p1 = null; // GC.Collect(); //判断p1是否已被回收,如果为false表示已经回收。 Console.W 阅读全文
posted @ 2011-05-19 18:45 winchou 阅读(260) 评论(1) 推荐(0) 编辑
摘要: list实现了IEnumerable泛型接口,所以list拥有Cast方法,然而转换给的时候如果类型不匹配就会转换失败OfType方法会忽略掉不能转换的元素.这让我想起了 is和as的区别 as转换失败会返回null 而is会报异常// ArrayList list = new ArrayList(); // list.Add(1); // list.Add(10); // list.Add(100); // list.Add("1000"); // //Cast<T>()会把序列中的所有元素都转换,如果类型不匹配,会转换失败 // //报异常。 // IEnu 阅读全文
posted @ 2011-05-19 18:41 winchou 阅读(175) 评论(0) 推荐(0) 编辑
摘要: 匿名方法:顾名思义就是没有方法名的方法以下是个人理解如有欠缺,敬请指点匿名方法一般是在委托中使用,组合起来的东西又叫lambda表达式,以下是一个简易的匿名方法.using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace linqlinq{ public delegate string Testdelegate(int n); class Program { /// <summary> /// 匿名方法 /// </summary> /// < 阅读全文
posted @ 2011-05-19 18:22 winchou 阅读(266) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace linqlinq{ class Program { /// <summary> /// 扩展方法 /// </summary> /// <param name="args"></param> static void Main(string[] args) { string s = "fdsfs"; Console.WriteL 阅读全文
posted @ 2011-05-19 18:14 winchou 阅读(174) 评论(0) 推荐(0) 编辑
摘要: //1 找出所有大于20的元素 int[] nums = { 30, 5, 99, 77, 102, 8, 12, 35 }; var result = from v in nums where v > 20 select v; foreach (var item in result) { Console.WriteLine(item); }////取出现次数最多的三个数 int[] values = { 1, 2, 5, 2, 3, 5, 5, 3, 4, 3, 3 }; var result = from v in values group v by v into g//取出来的元素 阅读全文
posted @ 2011-05-19 18:07 winchou 阅读(425) 评论(0) 推荐(0) 编辑
摘要: 大致思路:form1中定义一个委托,然后创建form2对象,通过form2的构造函数传过去一个方法作为参数,而在form2中声明一个委托类型的变量作为参数的构造函数...//form1中的代码using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace 窗口值1{ public deleg 阅读全文
posted @ 2011-05-18 20:36 winchou 阅读(496) 评论(0) 推荐(0) 编辑
摘要: 在创建实例的时候通过构造函数调用构造函数里面的方法只是构造函数其中的一个作用.在我看来,构造函数的大部分作用是在做参数传递.下面的这个例子说明:class Vehicle { public Vehicle() { } public Vehicle(string model) { this.model = model; } public Vehicle(string wheel, string color, string model) :this(model) { this.wheel = wheel; this.color = color; } protected string wheel; 阅读全文
posted @ 2011-04-27 21:36 winchou 阅读(1794) 评论(0) 推荐(0) 编辑