Book Review: C# 4.0 In a Nutshell [O'Reilly]

A review of the latest edition of C# 4.0 in a Nutshell, by Joseph and Ben Albahari

Some time ago, I reviewed this book's predecessor, "C# 3.0 in a Nutshell" and gave it high marks. My copy of that one is now dog-eared and actually has pages falling out from so much use over the last year or so.

The C# 3.0 edition had 838 pages including the index - this new volume has 1,023 pages! Like it's predecessor, the book is organized entirely around concepts and use cases, which makes it friendly to both sequential reading and random browsing. It covers C#, the CLR, and the core Framework assemblies. Features that are new to C# 4.0 are flagged so that the book can also serve as an excellent C# 3.0 reference.

This book, just like it's previous edition, is truly one of the most comprehensive volumes targeted at intermediate to advanced audiences that you will ever find, from any publisher. It reads more like a programmer's reference, and would complement more tutorial-style books.

C# 4.0 In a Nutshell contains over 100 pages dedicated to the new features of C# 4.0 and Framework 4.0. Many chapters have been enhanced over previous editions, including chapters on the C# language, .NET Framework fundamentals, memory management, threading and COM Interop. In addition, the LINQ chapters have been updated to cover both LINQ to SQL and the Entity Framework.

For Chapters 2 through 4, 6, 8 though 10, and Chapter 24, the code samples are available in the free LINQPad "IDE". I've been using LINQPad for quite some time, and I can state categorically that even if you do not purchase this book, go download a copy for yourself - its truly an amazing and very helpful application. Joe and Ben Albahari also have additional valuable companion information and articles on their web site.

The Table of Contents of the book, which comprises 26 chapters, really tells all about the breadth and depth of the coverage of the book:

  1. Chapter 1 Introducing C# and the .NET Framework
    1. Object Orientation
    2. Type Safety
    3. Memory Management
    4. Platform Support
    5. C#’s Relationship with the CLR
    6. The CLR and .NET Framework
    7. What’s New in C# 4.0
  2. Chapter 2 C# Language Basics
    1. A First C# Program
    2. Syntax
    3. Type Basics
    4. Numeric Types
    5. Boolean Type and Operators
    6. Strings and Characters
    7. Arrays
    8. Variables and Parameters
    9. Expressions and Operators
    10. Statements
    11. Namespaces
  3. Chapter 3 Creating Types in C#
    1. Classes
    2. Inheritance
    3. The object Type
    4. Structs
    5. Access Modifiers
    6. Interfaces
    7. Enums
    8. Nested Types
    9. Generics
  4. Chapter 4 Advanced C#
    1. Delegates
    2. Events
    3. Lambda Expressions
    4. Anonymous Methods
    5. try Statements and Exceptions
    6. Enumeration and Iterators
    7. Nullable Types
    8. Operator Overloading
    9. Extension Methods
    10. Anonymous Types
    11. Dynamic Binding
    12. Attributes
    13. Unsafe Code and Pointers
    14. Preprocessor Directives
    15. XML Documentation
  5. Chapter 5 Framework Overview
    1. The CLR and Core Framework
    2. Applied Technologies
  6. Chapter 6 Framework Fundamentals
    1. String and Text Handling
    2. Dates and Times
    3. Dates and Time Zones
    4. Formatting and Parsing
    5. Standard Format Strings and Parsing Flags
    6. Other Conversion Mechanisms
    7. Globalization
    8. Working with Numbers
    9. Enums
    10. Tuples
    11. The Guid Struct
    12. Equality Comparison
    13. Order Comparison
    14. Utility Classes
  7. Chapter 7 Collections
    1. Enumeration
    2. The ICollection and IList Interfaces
    3. The Array Class
    4. Lists, Queues, Stacks, and Sets
    5. Dictionaries
    6. Customizable Collections and Proxies
    7. Plugging in Equality and Order
  8. Chapter 8 LINQ Queries
    1. Getting Started
    2. Fluent Syntax
    3. Query Expressions
    4. Deferred Execution
    5. Subqueries
    6. Composition Strategies
    7. Projection Strategies
    8. Interpreted Queries
    9. LINQ to SQL and Entity Framework
    10. Building Query Expressions
  9. Chapter 9 LINQ Operators
    1. Overview
    2. Filtering
    3. Projecting
    4. Joining
    5. Ordering
    6. Grouping
    7. Set Operators
    8. The Zip Operator
    9. Conversion Methods
    10. Element Operators
    11. Aggregation Methods
    12. Quantifiers
    13. Generation Methods
  10. Chapter 10 LINQ to XML
    1. Architectural Overview
    2. X-DOM Overview
    3. Instantiating an X-DOM
    4. Navigating and Querying
    5. Updating an X-DOM
    6. Working with Values
    7. Documents and Declarations
    8. Names and Namespaces
    9. Annotations
    10. Projecting into an X-DOM
  11. Chapter 11 Other XML Technologies
    1. XmlReader
    2. XmlWriter
    3. Patterns for Using XmlReader/XmlWriter
    4. XmlDocument
    5. XPath
    6. XSD and Schema Validation
    7. XSLT
  12. Chapter 12 Disposal and Garbage Collection
    1. IDisposable, Dispose, and Close
    2. Automatic Garbage Collection
    3. Finalizers
    4. How the Garbage Collector Works
    5. Managed Memory Leaks
    6. Weak References
  13. Chapter 13 Diagnostics and Code Contracts
    1. Conditional Compilation
    2. Debug and Trace Classes
    3. Code Contracts Overview
    4. Preconditions
    5. Postconditions
    6. Assertions and Object Invariants
    7. Contracts on Interfaces and Abstract Methods
    8. Dealing with Contract Failure
    9. Selectively Enforcing Contracts
    10. Static Contract Checking
    11. Debugger Integration
    12. Processes and Process Threads
    13. StackTrace and StackFrame
    14. Windows Event Logs
    15. Performance Counters
    16. The Stopwatch Class
  14. Chapter 14 Streams and I/O
    1. Stream Architecture
    2. Using Streams
    3. Stream Adapters
    4. File and Directory Operations
    5. Memory-Mapped Files
    6. Compression
    7. Isolated Storage
  15. Chapter 15 Networking
    1. Network Architecture
    2. Addresses and Ports
    3. URIs
    4. Request/Response Architecture
    5. HTTP-Specific Support
    6. Writing an HTTP Server
    7. Using FTP
    8. Using DNS
    9. Sending Mail with SmtpClient
    10. Using TCP
    11. Receiving POP3 Mail with TCP
  16. Chapter 16 Serialization
    1. Serialization Concepts
    2. The Data Contract Serializer
    3. Data Contracts and Collections
    4. Extending Data Contracts
    5. The Binary Serializer
    6. Binary Serialization Attributes
    7. Binary Serialization with ISerializable
    8. XML Serialization
  17. Chapter 17 Assemblies
    1. What’s in an Assembly?
    2. Strong Names and Assembly Signing
    3. Assembly Names
    4. Authenticode Signing
    5. The Global Assembly Cache
    6. Resources and Satellite Assemblies
    7. Resolving and Loading Assemblies
    8. Deploying Assemblies Outside the Base Folder
    9. Packing a Single-File Executable
    10. Working with Unreferenced Assemblies
  18. Chapter 18 Reflection and Metadata
    1. Reflecting and Activating Types
    2. Reflecting and Invoking Members
    3. Reflecting Assemblies
    4. Working with Attributes
    5. Dynamic Code Generation
    6. Emitting Assemblies and Types
    7. Emitting Type Members
    8. Emitting Generic Methods and Types
    9. Awkward Emission Targets
    10. Parsing IL
  19. Chapter 19 Dynamic Programming
    1. The Dynamic Language Runtime
    2. Numeric Type Unification
    3. Dynamic Member Overload Resolution
    4. Implementing Dynamic Objects
    5. Interoperating with Dynamic Languages
  20. Chapter 20 Security
    1. Permissions
    2. Code Access Security (CAS)
    3. Allowing Partially Trusted Callers
    4. The Transparency Model in CLR 4.0
    5. Sandboxing Another Assembly
    6. Operating System Security
    7. Identity and Role Security
    8. Cryptography Overview
    9. Windows Data Protection
    10. Hashing
    11. Symmetric Encryption
    12. Public Key Encryption and Signing
  21. Chapter 21 Threading
    1. Threading’s Uses and Misuses
    2. Getting Started
    3. Thread Pooling
    4. Synchronization
    5. Locking
    6. Thread Safety
    7. Nonblocking Synchronization
    8. Signaling with Event Wait Handles
    9. Signaling with Wait and Pulse
    10. The Barrier Class
    11. The Event-Based Asynchronous Pattern
    12. BackgroundWorker
    13. Interrupt and Abort
    14. Safe Cancellation
    15. Lazy Initialization
    16. Thread-Local Storage
    17. Reader/Writer Locks
    18. Timers
  22. Chapter 22 Parallel Programming
    1. Why PFX?
    2. PLINQ
    3. The Parallel Class
    4. Task Parallelism
    5. Working with AggregateException
    6. Concurrent Collections
    7. SpinLock and SpinWait
  23. Chapter 23 Asynchronous Methods
    1. Why Asynchronous Methods Exist
    2. Asynchronous Method Signatures
    3. Asynchronous Methods Versus Asynchronous Delegates
    4. Using Asynchronous Methods
    5. Asynchronous Methods and Tasks
    6. Writing Asynchronous Methods
    7. Fake Asynchronous Methods
    8. Alternatives to Asynchronous Methods
  24. Chapter 24 Application Domains
    1. Application Domain Architecture
    2. Creating and Destroying Application Domains
    3. Using Multiple Application Domains
    4. Using DoCallBack
    5. Monitoring Application Domains
    6. Domains and Threads
    7. Sharing Data Between Domains
  25. Chapter 25 Native and COM Interoperability
    1. Calling into Native DLLs
    2. Type Marshaling
    3. Callbacks from Unmanaged Code
    4. Simulating a C Union
    5. Shared Memory
    6. Mapping a Struct to Unmanaged Memory
    7. COM Interoperability
    8. Calling a COM Component from C#
    9. Embedding Interop Types
    10. Primary Interop Assemblies
    11. Exposing C# Objects to COM
  26. Chapter 26 Regular Expressions
    1. Regular Expression Basics
    2. Quantifiers
    3. Zero-Width Assertions
    4. Groups
    5. Replacing and Splitting Text
    6. Cookbook Regular Expressions
    7. Regular Expressions Language Reference
  1. Appendix C# Keywords
  2. Colophon

C# 4.0 in a nutshell gets my highest marks for quality and coverage in a well-written, comprehensive book on the Framework 4.0 and the C# 4.0 language. A quick rundown of the "gurus" who served as advisors and technical editors speaks volumes about the book's quality, and includes notables such as Stephen Toub, Chris Burrows, Jon Skeet and Nicholas Paldino. Any developer who isn't familiar with these names must have been living in a cave!

If you only buy one programming book this year, I can confidently recommend that this is the one. You will not be disappointed.

By Peter Bromberg   Popularity  (3259 Views)