Ray's playground

 

随笔分类 -  C#

1 2 3 下一页

Constants and Fields(Chapter 7 of CLR via C#)
摘要:A constant is a symbol that has a never-changing value. When defining a constant symbol,its value must be determinable at compile time. The compiler then saves the constant’s valuein the assembly’s metadata. This means that you can define a constant only for types thatyour compiler considers primit. 阅读全文

posted @ 2011-08-04 23:39 Ray Z 阅读(253) 评论(0) 推荐(0)

Type and Member Basics(Chapter 6 of CLR via C#)
摘要:The CLR offers two IL instructions for calling a method: The call IL instruction can be used to call static, instance, and virtual methods.When the call instruction is used to call a static method, you must specify the typethat defines the method that the CLR should call. When the call instruction . 阅读全文

posted @ 2011-08-04 23:35 Ray Z 阅读(202) 评论(0) 推荐(0)

Primitive, Reference, and Value Types(Chapter 5 of CLR via C#)
摘要:You need to bear in mind some performance considerations when you’re working with reference types . First, consider these facts: The memory must be allocated from the managed heap . Each object allocated on the heap has some additional overhead members associatedwith it that must be initialized . T. 阅读全文

posted @ 2011-07-31 15:22 Ray Z 阅读(320) 评论(0) 推荐(0)

Type Fundamentals(Chapter 4 of CLR via C#)
摘要:Allobjects on the heap contain two overhead members: the type object pointer and the syncblock index. 阅读全文

posted @ 2011-07-29 23:47 Ray Z 阅读(158) 评论(0) 推荐(0)

Shared Assemblies and Strongly Named Assemblies(Chapter 3 of CLR via C#)
摘要:If an assembly is to be accessed by multiple applications, the assembly must be placed into awell-known directory, and the CLR must know to look in this directory automatically when areference to the assembly is detected. This well-known location is called the global assemblycache (GAC), which can . 阅读全文

posted @ 2011-04-21 08:28 Ray Z 阅读(195) 评论(0) 推荐(0)

Building, Packaging, Deploying, and Administering Applications and Types(Chapter 2 of CLR via C#)
摘要:A response file is a text file that contains a set of compiler commandlineswitches. When you execute CSC.exe, the compiler opens response files and uses anyswitches that are specified in them as though the switches were passed to CSC.exe on thecommand line. You instruct the compiler to use a respon. 阅读全文

posted @ 2011-04-20 11:08 Ray Z 阅读(214) 评论(0) 推荐(0)

The CLR’s Execution Model(Chapter 1 of CLR via C#)
摘要:The NGen.exe tool that ships with the .NET Framework can be used to compile IL code tonative code when an application is installed on a user’s machine. Since the code is compiledat install time, the CLR’s JIT compiler does not have to compile the IL code at runtime, andthis can improve the applicat. 阅读全文

posted @ 2011-04-18 22:00 Ray Z 阅读(236) 评论(0) 推荐(0)

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 阅读(202) 评论(0) 推荐(0)

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 阅读(252) 评论(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 阅读(250) 评论(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 阅读(303) 评论(0) 推荐(0)

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 阅读(211) 评论(0) 推荐(0)

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 阅读(199) 评论(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 阅读(188) 评论(0) 推荐(0)

Item 33: Use the new Modifier Only to React to Base Class Updates(Effective C#)
摘要:codeCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->1usingSystem;2usingSystem.Collections.Generic;3usingSystem.Linq;4usingSystem.Text;56namespaceEffectiveCSharpItem337{8classBase9{10publicvoidMagicMethod()11{12Console.WriteLine("magicmethodfr 阅读全文

posted @ 2011-02-22 21:43 Ray Z 阅读(270) 评论(0) 推荐(0)

Item 32: Avoid ICloneable(Effective C#)
摘要:ICloneable does have its use, but it is the exception rather than rule. It’s significantthat the .NET Framework did not add an ICloneable<T> when itwas updated with generic support. You should never add support forICloneable to value types; use the assignment operation instead. Youshould 阅读全文

posted @ 2011-02-21 21:06 Ray Z 阅读(178) 评论(0) 推荐(0)

Item 31: Implement Ordering Relations with IComparable<T> and IComparer<T>(Effective C#)
摘要:IComparable and IComparer are the standard mechanisms for providingordering relations for your types. IComparable should be used for themost natural ordering. When you implement IComparable, you shouldoverload the comparison operators (<, >, <=, >=) consistently with ourIComparable order 阅读全文

posted @ 2011-02-21 20:55 Ray Z 阅读(197) 评论(0) 推荐(0)

Item 30: Prefer Overrides to Event Handlers(Effective C#)
摘要:When you have one function that handles one event in a derived class, theoverride is the better approach. It is easier to maintain, more likely to becorrect over time, and more efficient. Reserve the event handlers for otheruses. Prefer overriding the base class implementation to attaching an eventh 阅读全文

posted @ 2011-02-19 13:06 Ray Z 阅读(215) 评论(0) 推荐(0)

Item 29: Support Generic Covariance and Contravariance(Effective C#)
摘要:It certainly can get complicated describing exactly how covariance andcontravariance work. Thankfully, now the language supports decoratinggeneric interfaces and delegates with in (contravariant) and out (covariant)modifiers. You should decorate any interfaces and delegates you definewith the in or 阅读全文

posted @ 2011-02-19 11:12 Ray Z 阅读(149) 评论(0) 推荐(0)

Item 28: Create Large-Grain Internet Service APIs(Effective C#)
摘要:Nothing special. 阅读全文

posted @ 2011-02-17 21:28 Ray Z 阅读(139) 评论(0) 推荐(0)

1 2 3 下一页

导航