文件名称:Effective C# (Covers C# 4.0) Mar 2010
文件大小:5.15MB
文件格式:PDF
更新时间:2013-04-27 04:06:23
Effective C#4.0
Effective C# (Covers C# 4.0): 50 Specific Ways to Improve Your C#, Second Edition
352 pages
Publisher: Addison-Wesley Professional; 2 edition (March 15, 2010)
Language: English
ISBN-10: 0321658701
ISBN-13: 978-0321658708
You’ll learn how to
Use both types of C# constants for efficiency and maintainability (see Item 2)
Employ immutable data types to promote multicore processing (see Item 20)
Minimize garbage collection, boxing, and unboxing (see Items 16 and 45)
Take full advantage of interfaces and delegates (see Items 22 though 25)
Make the most of the parallel framework (see Items 35 through 37)
Use duck typing in C# (see Item 38)
Spot the advantages of the dynamic and Expression types over reflection (see Items 42 and 43)
Assess why query expressions are better than loops (see Item 8)
Understand how generic covariance and contravariance affect your designs (see Item 29)
See how optional parameters can minimize the number of method overloads (see Item 10)
Chapter 1 C# Language Idioms 1
Item 1: Use Properties Instead of Accessible Data Members 1
Item 2: Prefer readonly to const 8
Item 3: Prefer the is or as Operators to Casts 12
Item 4: Use Conditional Attributes Instead of #if 20
Item 5: Always Provide ToString() 28
Item 6: Understand the Relationships Among the Many Different
Concepts of Equality 36
Item 7: Understand the Pitfalls of GetHashCode() 44
Item 8: Prefer Query Syntax to Loops 51
Item 9: Avoid Conversion Operators in Your APIs 56
Item 10: Use Optional Parameters to Minimize Method Overloads 60
Item 11: Understand the Attraction of Small Functions 64
Chapter 2 .NET Resource Management 69
Item 12: Prefer Member Initializers to Assignment Statements 74
Item 13: Use Proper Initialization for Static Class Members 77
Item 14: Minimize Duplicate Initialization Logic 79
Item 15: Utilize using and try/finally for Resource Cleanup 87
Item 16: Avoid Creating Unnecessary Objects 94
Item 17: Implement the Standard Dispose Pattern 98
Item 18: Distinguish Between Value Types and Reference Types 104
Item 19: Ensure That 0 Is a Valid State for Value Types 110
Item 20: Prefer Immutable Atomic Value Types 114
Chapter 3 Expressing Designs in C# 125
Item 21: Limit Visibility of Your Types 126
Item 22: Prefer Defining and Implementing Interfaces to Inheritance 129
Item 23: Understand How Interface Methods Differ from Virtual
Methods 139
Item 24: Express Callbacks with Delegates 143
Item 25: Implement the Event Pattern for Notifications 146
Item 26: Avoid Returning References to Internal Class Objects 154
Item 27: Prefer Making Your Types Serializable 157
Item 28: Create Large-Grain Internet Service APIs 166
Item 29: Support Generic Covariance and Contravariance 171
Chapter 4 Working with the Framework 179
Item 30: Prefer Overrides to Event Handlers 179
Item 31: Implement Ordering Relations with IComparable