C# 5.0 in a Nutshell: The Definitive Reference

Front Cover
"O'Reilly Media, Inc.", Jun 19, 2012 - Computers - 1064 pages

When you have a question about C# 5.0 or the .NET CLR, this bestselling guide has precisely the answers you need. Uniquely organized around concepts and use cases, this updated fifth edition features a reorganized section on concurrency, threading, and parallel programming—including in-depth coverage of C# 5.0’s new asynchronous functions.

Shaped by more than 20 expert reviewers, including Microsoft’s Eric Lippert, Stephen Toub, Chris Burrows, and Jon Skeet, this book has all you need to stay on track with C# 5.0. It’s widely known as the definitive reference on the language.

  • Get up to speed on C# language basics, including syntax, types, and variables
  • Explore advanced topics such as unsafe code and type variance
  • Dig deep into LINQ via three chapters dedicated to the topic
  • Learn about code contracts, dynamic programming, and parallel programming
  • Work with .NET features, including reflection, assemblies, memory management, security, I/O, XML, collections, networking, and native interoperability

"C# 5.0 in a Nutshell is one of the few books I keep on my desk as a quick reference."

—Scott Guthrie, Microsoft

"Whether you’re a novice programmer or an expert who wants to improve your knowledge of modern asynchronous programming techniques, this book has the information you need to get the job done in C#."

—Eric Lippert, Microsoft

From inside the book

What people are saying - Write a review

User Review - Flag as inappropriate

The author has tons n tons of knowledge. I turned on to this book for learning Linq. And even when the book says "C# in a nutshell", still author has given enough of explanation and knowledge on each concept pertaining to Linq. This has made me hungry to read many more chapters from this book.
Great work Joseph Albahari, for this book and the LinqPad (http://www.linqpad.net/)
 

Selected pages

Contents

Chapter 15 Streams and IO
Using Streams
Stream Adapters
Compression Streams
Working with Zip Files
File and Directory Operations
File IO in Windows Runtime
MemoryMapped Files

Memory Management
Cs Relationship with the CLR
C and Windows Runtime
Whats New in C 50
Whats New in C 30
Chapter 2 C Language Basics
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
Inheritance
The object Type
Structs
Access Modifiers
Interfaces
Enums
Nested Types
Generics
Chapter 4 Advanced C
Events
Lambda Expressions
Anonymous Methods
try Statements and Exceptions
Enumeration and Iterators
Nullable Types
Operator Overloading
Extension Methods
Anonymous Types
Dynamic Binding
Attributes
Caller Info Attributes C 5
Unsafe Code and Pointers
Preprocessor Directives
XML Documentation
Chapter 5 Framework Overview
The CLR and Core Framework
Applied Technologies
Chapter 6 Framework Fundamentals
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
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
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
Conversion Methods
Element Operators
Aggregation Methods
Quantifiers
Generation Methods
Chapter 10 LINQ to XML
XDOM Overview
Instantiating an XDOM
Navigating and Querying
Updating an XDOM
Working with Values
Documents and Declarations
Names and Namespaces
Annotations
Projecting into an XDOM
Chapter 11 Other XML Technologies
XmlReader
XmlWriter
Patterns for Using XmlReaderXmlWriter
XmlDocument
XPath
XSD and Schema Validation
XSLT
Chapter 12 Disposal and Garbage Collection
Automatic Garbage Collection
Finalizers
How the Garbage Collector Works
Managed Memory Leaks
Weak References
Chapter 13 Diagnostics and Code Contracts
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 Concurrency Asynchrony
Threading
Tasks
Principles of Asynchrony
Asynchronous Functions in C 50
Asynchronous Patterns
Obsolete Patterns
Isolated Storage
Chapter 16 Networking
Addresses and Ports
URIs
ClientSide Classes
Working with HTTP
Writing an HTTP Server
Using FTP
Using DNS
Sending Mail with SmtpClient
Using TCP
Receiving POP3 Mail with TCP
TCP in Windows Runtime
Chapter 17 Serialization
The Data Contract Serializer
Data Contracts and Collections
Extending Data Contracts
The Binary Serializer
Binary Serialization Attributes
Binary Serialization with ISerializable
XML Serialization
Chapter 18 Assemblies
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 SingleFile Executable
Working with Unreferenced Assemblies
Chapter 19 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 20 Dynamic Programming
Numeric Type Unification
Dynamic Member Overload Resolution
Implementing Dynamic Objects
Interoperating with Dynamic Languages
Chapter 21 Security
Code Access Security CAS
Allowing Partially Trusted Callers
The Transparency Model
Sandboxing Another Assembly
Operating System Security
Identity and Role Security
Cryptography Overview
Windows Data Protection
Hashing
Symmetric Encryption
Public Key Encryption and Signing
Chapter 22 Advanced Threading
Synchronization Overview
Exclusive Locking
Locking and Thread Safety
NonExclusive Locking
Signaling with Event Wait Handles
The Barrier Class
Lazy Initialization
ThreadLocal Storage
Interrupt and Abort
Suspend and Resume
Timers
Chapter 23 Parallel Programming
PLINQ
The Parallel Class
Task Parallelism
Working with AggregateException
Concurrent Collections
BlockingCollectionT
Chapter 24 Application Domains
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
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
ZeroWidth Assertions
Groups
Replacing and Splitting Text
Cookbook Regular Expressions
Regular Expressions Language Reference
Index
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
About the Authors
Colophon
Upgrade this ebook with OReilly
Copyright

Common terms and phrases

About the author (2012)

Joseph Albahari is author of C# 3.0 in a Nutshell, LINQ Pocket Reference, and C# 3.0 Pocket Reference. He has been developing large-scale enterprise applications on .NET and other platforms for more than 15 years, and is author of LINQPad - the popular utility for querying databases in LINQ.

Joseph is currently a freelance consultant.

Joseph's Home Page

Ben Albahari is the founder of Take On It. He was a Program Manager at Microsoft for 5 years, where he worked on several projects, including the .NET Compact Framework and ADO.NET.

He was the cofounder of Genamics, a provider of tools for C# and J++ programmers, as well as software for DNA and protein sequence analysis. He is a co-author of C# Essentials, the first C# book from O'Reilly, and of previous editions of C# in a Nutshell.

Bibliographic information