上一页 1 ··· 370 371 372 373 374 375 376 377 378 ··· 382 下一页
摘要: ASHX内容: #region IHttpHandler Members public void ProcessRequest(HttpContext context) { context.Response.ContentType = "application/x-javascript"; List<User> list = new List<User>(); for (int i = 0; i < 10; i++) { list.Add(new User { UserName = "zzl" + i, Tel = &quo 阅读全文
posted @ 2011-05-27 16:47 张占岭 阅读(2537) 评论(1) 推荐(0)
摘要: JS扩展方法:通过原型prototype为JS的function扩展一个新的function<script> function Rectangle(width, height) { this.width = width; this.height = height; } //为js的一个function添加一个方法,即我们通过原型prototype为一个class添加一个method Rectangle.prototype.adds = function (rec) { if (rec instanceof Rectangle) { return (rec.width*rec.hei 阅读全文
posted @ 2011-05-26 18:04 张占岭 阅读(429) 评论(0) 推荐(0)
摘要: 今天的主角是ref和out这两个参数!Ref和out它们是方法中的参数修饰符,有什么作用呢,其实可以这样理解,它们加上参数后会使用地址进行传递,说的明白点就是当定义变量a后,把它再作为ref或out参数进行传递到子方法,然后它的计算结果还会返回到这个变量之中.#region ref and out reference public class RefOrOut { public void Ref(ref int a) { a = a + 1; } public void Out(out int b) { b = 0; b = b + 1; } }#endregion调用代码:RefOrOut 阅读全文
posted @ 2011-05-26 15:29 张占岭 阅读(526) 评论(0) 推荐(0)
摘要: 接口与抽象类这两个家伙是被人们说的最多的东西了,在概念上我不想再多说了,我只是想把它们俩个在项目的应用上简单来说两句.接口,规定了一些必须被实现的行为,即只要是继承了接口,那么接口里的所有方法你都要继承,当然,如果有些方法对于你没有任何实现的价值,你也可以不去实现它,你抛一个这样的异常出来: /// <summary> /// 人类的行为 /// </summary> public interface PeopleEvent { /// <summary> /// 走路 /// </summary> void Walk(); /// <su 阅读全文
posted @ 2011-05-25 17:47 张占岭 阅读(376) 评论(0) 推荐(0)
摘要: 一,人类的起源,及人类的爬,走,跑是怎么炼成的.1 类和结构,继承和方法复写及扩展方法及部分类面向对象最重要的元素之一,它是对外部世界的抽象,我们来看一个最标准的类: /// <summary> /// 一个人 /// </summary> public class People { /// <summary> /// 默认构造函数,建议要有一个 /// </summary> public People() { } /// <summary> /// 只初始化人的姓名 /// </summary> /// <para 阅读全文
posted @ 2011-05-24 17:18 张占岭 阅读(553) 评论(0) 推荐(0)
上一页 1 ··· 370 371 372 373 374 375 376 377 378 ··· 382 下一页