Ray's playground

 
上一页 1 ··· 12 13 14 15 16 17 18 19 20 ··· 56 下一页

2011年2月26日

Item 40: Use Dynamic for Parameters That Receive Anonymous Types(Effective C#)

摘要: You can leverage dynamic to create methods that are intended to be usedwith anonymous types. It’s a technique to be used sparingly, like strongspices. If you find yourself creating many methods using dynamic invocationthat are intended for use with anonymous types, that’s a strong indicationthat yo. 阅读全文

posted @ 2011-02-26 10:38 Ray Z 阅读(193) 评论(0) 推荐(0) 编辑

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) 编辑

2011年2月24日

Item 36: Understand How to Use PLINQ for I/O Bound Operations(Effective C#)

摘要: The Parallel Task Library provides a series of methods that enable workingwith I/O bound operations as well as CPU bound partitions of work.Using the Task class, you can support a variety of asynchronous patternsthat work with I/O bound operations, or those that are a mixture of I/Oand CPU bound op. 阅读全文

posted @ 2011-02-24 22:37 Ray Z 阅读(201) 评论(0) 推荐(0) 编辑

Images and Mouse Events(Chapter 18 of Cocoa Programming for Mac OS X)

摘要: 1#import"StretchView.h"234@implementationStretchView56-(id)initWithFrame:(NSRect)rect7{8if(![superinitWithFrame:rect])9{10returnnil;11}1213srandom(time(NULL));1415path=[[NSBezierPathalloc]init];16[pathsetLineWidth:3.0];17NSPointp=[selfrandomPoint];18[pathmoveToPoint:p];19inti;20for(i=0;i&l 阅读全文

posted @ 2011-02-24 16:53 Ray Z 阅读(252) 评论(0) 推荐(0) 编辑

Custom Views(Chapter 17 of Cocoa Programming for Mac OS X)

摘要: #import"StretchView.h"@implementationStretchView-(id)initWithFrame:(NSRect)rect{if(![superinitWithFrame:rect]){returnnil;}srandom(time(NULL));path=[[NSBezierPathalloc]init];[pathsetLineWidth:3.0];NSPointp=[selfrandomPoint];[pathmoveToPoint:p];inti;for(i=0;i<15;i++){p=[selfrandomPoint];[ 阅读全文

posted @ 2011-02-24 11:17 Ray Z 阅读(196) 评论(0) 推荐(0) 编辑

2011年2月23日

Item 35: Learn How PLINQ Implements Parallel Algorithms(Effective C#)

摘要: Every parallel query begins with a partitioning step. PLINQ needs to partitionthe input elements and distribute those over the number of taskscreated to perform the query. Partitioning is one of the most importantaspects of PLINQ, so it is important to understand the differentapproaches, how PLINQ . 阅读全文

posted @ 2011-02-23 20:48 Ray Z 阅读(179) 评论(0) 推荐(0) 编辑

Item 34: Avoid Overloading Methods Defined in Base Classes(Effective C#)

摘要: 1usingSystem;2usingSystem.Collections.Generic;3usingSystem.Linq;4usingSystem.Text;56namespaceEffectiveCSharpItem347{8publicclassB2{}9publicclassD2:B2{}1011publicclassB12{13publicvoidFoo(D2parm)14{15Console.WriteLine("InB.Foo");16}17publicvoidBar(B2parm)18{19Console.WriteLine("InB.Bar& 阅读全文

posted @ 2011-02-23 20:08 Ray Z 阅读(180) 评论(0) 推荐(0) 编辑

上一页 1 ··· 12 13 14 15 16 17 18 19 20 ··· 56 下一页

导航