Book description
What people are saying about C# 4.0 in a Nutshell
"C# 4.0 in a Nutshell is one of the few books I keep on my desk as a quick reference. It is a book I recommend."--Scott Guthrie, Corporate Vice President, .NET Developer Platform, Microsoft Corporation
"A must-read for a concise but thorough examination of the parallel programming features in the .NET Framework 4."--Stephen Toub, Parallel Computing Platform Program Manager, Microsoft
"This wonderful book is a great reference for developers of all levels."-- Chris Burrows, C# Compiler Team, Microsoft
When you have questions about how to use C# 4.0 or the .NET CLR, this highly acclaimed bestseller has precisely the answers you need. Uniquely organized around concepts and use cases, this fourth edition includes in-depth coverage of new C# topics such as parallel programming, code contracts, dynamic programming, security, and COM interoperability. You'll also find updated information on LINQ, including examples that work with both LINQ to SQL and Entity Framework. This book has all the essential details to keep you on track with C# 4.0.
- Get up to speed on C# language basics, including syntax, types, and variables
- Explore advanced topics such as unsafe code and preprocessor directives
- Learn C# 4.0 features such as dynamic binding, type parameter variance, and optional and named parameters
- Work with .NET 4's rich set of features for parallel programming, code contracts, and the code security model
- Learn .NET topics, including XML, collections, I/O and networking, memory management, reflection, attributes, security, and native interoperability
Table of contents
- C# 4.0 in a Nutshell
- A Note Regarding Supplemental Files
- Preface
- 1. Introducing C# and the .NET Framework
-
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
-
3. Creating Types in C#
- Classes
- Inheritance
- The object Type
- Structs
- Access Modifiers
- Interfaces
- Enums
- Nested Types
-
Generics
- Generic Types
- Why Generics Exist
- Generic Methods
- Declaring Type Parameters
- typeof and Unbound Generic Types
- The default Generic Value
- Generic Constraints
- Subclassing Generic Types
- Self-Referencing Generic Declarations
- Static Data
- Type Parameters and Conversions
- Covariance
- Contravariance
- C# Generics Versus C++ Templates
-
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
- 5. Framework Overview
-
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
- 7. Collections
-
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
- 9. LINQ Operators
- 10. LINQ to XML
- 11. Other XML Technologies
- 12. Disposal and Garbage Collection
-
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
- 14. Streams and I/O
- 15. Networking
- 16. Serialization
-
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
-
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
- 19. Dynamic Programming
- 20. Security
-
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
-
22. Parallel Programming
- Why PFX?
- PLINQ
- The Parallel Class
- Task Parallelism
- Working with AggregateException
- Concurrent Collections
- SpinLock and SpinWait
- 23. Asynchronous Methods
- 24. Application Domains
- 25. Native and COM Interoperability
-
26. Regular Expressions
- Regular Expression Basics
- Quantifiers
- Zero-Width Assertions
- Groups
- Replacing and Splitting Text
-
Cookbook Regular Expressions
-
Recipes
- Matching U.S. Social Security number/phone number
- Extracting “name = value” pairs (one per line)
- Strong password validation
- Lines of at least 80 characters
- Parsing dates/times (N/N/N H:M:S AM/PM)
- Matching Roman numerals
- Removing repeated words
- Word count
- Matching a Guid
- Parsing an XML/HTML tag
- Splitting a camel-cased word
- Obtaining a legal filename
- Escaping Unicode characters for HTML
- Unescaping characters in an HTTP query string
- Parsing Google search terms from a web stats log
-
Recipes
- Regular Expressions Language Reference
- A. C# Keywords
- Index
- About the Authors
- Colophon
- Copyright
Product information
- Title: C# 4.0 in a Nutshell, 4th Edition
- Author(s):
- Release date: February 2010
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9780596800956
You might also like
book
Microsoft Windows 2000 API SuperBible
Following in the tradition of the Win 95 and Win32 NT SuperBibles, this book is a …
book
Microsoft IIS 10.0 Cookbook
Over 60 recipes to install, configure, and manage your IIS 10.0 About This Book Provide a …
book
Effective C#: 50 Specific Ways to Improve Your C#, Third Edition
In respected .NET expert Bill Wagner identifies 50 ways to harness the full power of the …
book
Analytical Skills for AI and Data Science
While several market-leading companies have successfully transformed their business models by following data- and AI-driven paths, …