Ray's playground

 

2011年2月25日

Item 39: Use Dynamic to Leverage the Runtime Type of Generic Type Parameters(Effective C#)

摘要: Cast<T>, like all generic methods, compiles with only limited knowledgeof its type parameters. That can lead to generic methods not working theway you’d expect. The root cause is almost always that the generic methodcould not be made aware of particular functionality in the type representingth 阅读全文

posted @ 2011-02-25 23:56 Ray Z 阅读(235) 评论(0) 推荐(0) 编辑

Item 38: Understand the Pros and Cons of Dynamic(Effective C#)

摘要: There are also performance costs with using dynamic and with buildingexpressions at runtime. Just like any dynamic type system, your programhas more work to do at runtime because the compiler did not performany of its usual type checking. The compiler must generate instructions toperform all those . 阅读全文

posted @ 2011-02-25 22:36 Ray Z 阅读(237) 评论(0) 推荐(0) 编辑

Item 37: Construct Parallel Algorithms with Exceptions in Mind(Effective C#)

摘要: Exceptions are complicated in any algorithm. Parallel tasks create morecomplications. The Parallel Task Library uses the AggregateException classto hold any and all exceptions thrown somewhere in the depths of yourparallel algorithms. Once any of the background threads throws an exception,any other. 阅读全文

posted @ 2011-02-25 21:16 Ray Z 阅读(292) 评论(0) 推荐(0) 编辑

An Objective-C Primer(Chapter 2 of Objective-C Phrasebook)

摘要: #import<Foundation/Foundation.h>int(^getCounter(void))(void){__blockintcounter;int(^block)(void)=^(void){returncounter++;};return_Block_copy(block);}intmain(void){int(^block)(void)=getCounter();block();block();NSCAssert(block()==2,@"Blockcountedincorrectly");int(^block2)(void)=getCou 阅读全文

posted @ 2011-02-25 18:33 Ray Z 阅读(156) 评论(0) 推荐(0) 编辑

导航