Book description
C# 2010 offers powerful new features, and this book is the fastest path to mastering them—and the rest of C#—for both experienced C# programmers moving to C# 2010 and programmers moving to C# from another object-oriented language. Many books introduce C#, but very few also explain how to use it optimally with the .NET Common Language Runtime (CLR). This book teaches both core C# language concepts and how to wisely employ C# idioms and object-oriented design patterns to exploit the power of C# and the CLR.
This book is both a rapid tutorial and a permanent reference. You'll quickly master C# syntax while learning how the CLR simplifies many programming tasks. You'll also learn best practices that ensure your code will be efficient, reusable, and robust. Why spend months or years discovering the best ways to design and code C# when this book will show you how to do things the right way from the start?
Comprehensively and concisely explains both C# 2008 and C# 2010 features
Focuses on the language itself and on how to use C# 2010 proficiently for all .NET application development.
Concentrates on how C# features work and how to best use them for robust, high-performance code
Table of contents
- Copyright
- About the Author
- About the Technical Reviewer
- Acknowledgments
- Preface
- 1. C# Preview
- 2. C# and the CLR
- 3. C# Syntax Overview
-
4. Classes, Structs, and Objects
-
4.1. Class Definitions
- 4.1.1. Fields
- 4.1.2. Constructors
- 4.1.3. Methods
- 4.1.4. Properties
- 4.1.5. Encapsulation
- 4.1.6. Accessibility
- 4.1.7. Interfaces
- 4.1.8. Inheritance
- 4.1.9. sealed Classes
- 4.1.10. abstract Classes
- 4.1.11. Nested Classes
- 4.1.12. Indexers
- 4.1.13. partial Classes
- 4.1.14. partial Methods
- 4.1.15. Static Classes
- 4.1.16. Reserved Member Names
- 4.2. Value Type Definitions
- 4.3. Anonymous Types
- 4.4. Object Initializers
- 4.5. Boxing and Unboxing
- 4.6. System.Object
- 4.7. Creating Objects
- 4.8. Destroying Objects
- 4.9. Disposable Objects
- 4.10. Method Parameter Types
- 4.11. Inheritance and Virtual Methods
- 4.12. Inheritance, Containment, and Delegation
- 4.13. Summary
-
4.1. Class Definitions
- 5. Interfaces and Contracts
- 6. Overloading Operators
-
7. Exception Handling and Exception Safety
- 7.1. How the CLR Treats Exceptions
-
7.2. Mechanics of Handling Exceptions in C#
- 7.2.1. Throwing Exceptions
- 7.2.2. Changes with Unhandled Exceptions Starting with .NET 2.0
- 7.2.3. Syntax Overview of the try, catch, and finally Statements
- 7.2.4. Rethrowing Exceptions and Translating Exceptions
- 7.2.5. Exceptions Thrown in finally Blocks
- 7.2.6. Exceptions Thrown in Finalizers
- 7.2.7. Exceptions Thrown in Static Constructors
- 7.3. Who Should Handle Exceptions?
- 7.4. Avoid Using Exceptions to Control Flow
- 7.5. Achieving Exception Neutrality
- 7.6. Creating Custom Exception Classes
- 7.7. Working with Allocated Resources and Exceptions
- 7.8. Providing Rollback Behavior
- 7.9. Summary
- 8. Working with Strings
- 9. Arrays, Collection Types, and Iterators
- 10. Delegates, Anonymous Functions, and Events
-
11. Generics
- 11.1. Difference Between Generics and C++ Templates
- 11.2. Efficiency and Type Safety of Generics
- 11.3. Generic Type Definitions and Constructed Types
- 11.4. Constraints
- 11.5. Co- and Contravariance
- 11.6. Generic System Collections
- 11.7. Generic System Interfaces
- 11.8. Select Problems and Solutions
- 11.9. Summary
-
12. Threading in C#
-
12.1. Threading in C# and .NET
- 12.1.1. Starting Threads
- 12.1.2. The IOU Pattern and Asynchronous Method Calls
- 12.1.3. States of a Thread
- 12.1.4. Terminating Threads
- 12.1.5. Halting Threads and Waking Sleeping Threads
- 12.1.6. Waiting for a Thread to Exit
- 12.1.7. Foreground and Background Threads
- 12.1.8. Thread-Local Storage
- 12.1.9. How Unmanaged Threads and COM Apartments Fit In
- 12.2. Synchronizing Work Between Threads
- 12.3. Using ThreadPool
- 12.4. Concurrent Programming
- 12.5. Thread-Safe Collection Classes
- 12.6. Summary
-
12.1. Threading in C# and .NET
-
13. In Search of C# Canonical Forms
-
13.1. Reference Type Canonical Forms
- 13.1.1. Default to sealed Classes
- 13.1.2. Use the Non-Virtual Interface (NVI) Pattern
- 13.1.3. Is the Object Cloneable?
- 13.1.4. Is the Object Disposable?
- 13.1.5. Does the Object Need a Finalizer?
- 13.1.6. What Does Equality Mean for This Object?
- 13.1.7. If You Override Equals, Override GetHashCode Too
- 13.1.8. Does the Object Support Ordering?
- 13.1.9. Is the Object Formattable?
- 13.1.10. Is the Object Convertible?
- 13.1.11. Prefer Type Safety at All Times
- 13.1.12. Using Immutable Reference Types
- 13.2. Value Type Canonical Forms
- 13.3. Summary
-
13.1. Reference Type Canonical Forms
- 14. Extension Methods
- 15. Lambda Expressions
- 16. LINQ: Language Integrated Query
- 17. Dynamic Types
Product information
- Title: Accelerated C# 2010
- Author(s):
- Release date: January 2010
- Publisher(s): Apress
- ISBN: 9781430225379
You might also like
book
C# 4.0 Unleashed
C# 4.0 Unleashed is a practical reference focusing on the C# language and the .NET platform …
book
Professional C# 5.0 and .NET 4.5.1
Comprehensive, advanced coverage of C# 5.0 and .NET 4.5.1 Whether you're a C# guru or transitioning …
book
C# 3.0 Unleashed: With the .NET Framework 3.5
Whether you need an approachable on-ramp to .NET or you want to enhance your skills, C# …
book
Microsoft® Visual C#® .NET 2003 Unleashed
Microsoft Visual C# .NET 2003 Unleashed is a comprehensive reference and learning guide for the .NET …