《More Effective C#:改善C#程序的50个具体办法来自》,是2009年人民邮360百科电出版社出版的图书,作者是瓦格纳。
本书针对C# 2.0和3.0中添加的新特性给出了改善C#代码的50条实用建议,其中着重介绍了泛型技术,这是C# 2.0和3.0中众多新特性的基石。本书按照建议的主题进行分类,其中每个建议针对某个特定问题进行展开,分析了问题的原因,给出解决的办法。
本书适合各层次.NET开发人员阅读。
Chapter 1. Working with Generics
Item 1. Use G来自eneric Replacements of 1.x Framework API Classes
Item 2. Define Constraints That Are Minimal and Sufficient
Item 3直殖许财脚景月岁. Specialize Generic Algorithms Using Runtime Type Checki360百科ng
Item 灯气制划策苗她洲也4. Use Generics to Force Co坐线青蒸镇义一建mpile-Time Typ传老存团钟述倒互自答e Inference
Item 5. Ensure That Your Generic Classes Support Disposable Type Parameters
Item 6. Use Delegates to Define Method Constraints on Type Parameters
Item 7需构盟翻联. Do Not Create Generic Specialization on Base Classes or Int末粉黄器察院等erfaces
Item 8. Prefer Gener井另觉例友确ic Methods Unless Type Parameters Are Instance Fields
Item 9. Prefer Generic Tuples to Output and Ref Para该条容济格meters
Item 10. Implement Classic Inter乐探逐危企李顺鸡faces in Addition to Generic Interfaces
Chapter 2. Multithreading in C#
Item 11. Use the Thread Pool 黄棉依乡Instead of Creating Threads
Item 12. Use BackgroundWorker for Cross-Thread Commun压能ication
Item 使13. Use lock() as Your First Choice for Synchro扩光求调频便基座欢呀nization
映且书为都 Item 14. Use the Smallest Possibl武九e Scope for Lock Handles
Item 15. Avoid Calling Unknown Code in Locked Sections
Item 16. Understand Cross-Thread Calls in Windows Forms and WPF
Chapter 3. C# Des支让杀历跳青坚ign Pract晚声宽鲜似利川ices
Item 17. Create Composable APIs for Sequences
Item 18. Decouple Iterations from Actions, Predicates, and Functions
Item 19. Generate Sequence Items as Requested
It酸殖呀头解社位em 20. Loosen Coupling by Using Function Parameters
Item 21. Create Method Groups That Are Clear, Minimal, and Complete
Item 22. Prefer Defining Methods to Overloading Operators
Item 23. Understand How Events Increase Runtime Coupling Among Objects
Item 24. Declare Only Nonvirtual Events
Item 25. Use Exceptions to Report Method Contract Failures
Item 26. Ensure That Properties Behave Like Data
Item 27. Distinguish Between Inheritance and Composition
Chapter 4. C# 3.0 Language Enhancements
Item 28. Augment Minimal Interface Contracts with Extension Methods
Item 29. Enhance Constructed Types with Extension Methods
Item 30. Prefer Implicitly Typed Local Variables
Item 31. Limit Type Scope by Using Anonymous Types
Item 32. Create Composable APIs for External Components
Item 33. Avoid Modifying Bound Variables
Item 34. Define Local Functions on Anonymous Types
Item 35. Never Overload Extension Methods
Chapter 5. Working with LINQ
Item 36. Understand How Query Expressions Map to Method Calls
Item 37. Prefer Lazy Evaluation Queries
Item 38. Prefer Lambda Expressions to Methods
Item 39. Avoid Throwing Exceptions in Functions and Actions
Item 40. Distinguish Early from Deferred Execution
Item 41. Avoid Capturing Expensive Resources
Item 42. Distinguish Between IEnumerable and IQueryable Data Sources
Item 43. Use Single() and First() to Enforce Semantic Expectations on Queries
Item 44. Prefer Storing Expression to Func
Chapter 6. Miscellaneous
Item 45. Minimize the Visibility of Nullable Values
Item 46. Give Partial Classes Partial Methods for Constructors, Mutators, and Event Handlers
Item 47. Limit Array Parameters to Params Arrays
Item 48. Avoid Calling Virtual Functions in Constructors
Item 49. Consider Weak References for Large Objects
Item 50. Prefer Implicit Properties for Mutable, Nonserializable Data
Index