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