摘要: 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 张占岭 阅读(417) 评论(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 张占岭 阅读(512) 评论(0) 推荐(0) 编辑