What is in this book
Contents
Foreword
About the Author
About the Technical Reviewer
Acknowledgments
Introduction
CHAPTER 1: C# Preview
Differences Between C# and C++
C# 1
C++
CLR Garbage Collection
Example of a C# Program
Overview of Features Added in C# 2.0
Overview of What’s New in C# 3.0
Summary
CHAPTER 2: C# and the CLR
The JIT Compiler in the CLR
Assemblies and the Assembly Loader
Minimizing the Working Set of the Application
Naming Assemblies
Loading Assemblies
Metadata
Cross-Language Compatibility
Summary
CHAPTER 3: C# Syntax Overview
C# Is a Strongly Typed Language
Expressions
Statements and Expressions
Types and Variables
Value Types
Reference Types
Default Variable Initialization
Implicitly Typed Local Variables
Type Conversion
as and is Operators
Generics
Namespaces
Defining Namespaces
Using Namespaces
Control Flow
if-else, while, do-while, and for
switch
foreach
break, continue, goto, return, and throw
Summary
CHAPTER 4: Classes, Structs, and Objects
Class Definitions
Fields
Constructors
Methods
Properties
Encapsulation
Accessibility
Interfaces
Inheritance
sealed Classes
abstract Classes
Nested Classes
Indexers
partial Classes
partial Methods
Static Classes
Reserved Member Names
Value Type Definitions
Constructors
The Meaning of this
Finalizers
Interfaces
Anonymous Types
Object Initializers
Boxing and Unboxing
When Boxing Occurs
Efficiency and Confusion
System.Object
Equality and What It Means
The IComparable Interface
Creating Objects
The new Keyword
Field Initialization
Static (Class) Constructors
Instance Constructor and Creation Ordering
Destroying Objects
Finalizers
Deterministic Destruction
Exception Handling
Disposable Objects
The IDisposable Interface
The using Keyword
Method Parameter Types
Value Arguments
ref Arguments
out Parameters
param Arrays
Method Overloading
Inheritance and Virtual Methods
Virtual and Abstract Methods
override and new Methods
sealed Methods
A Final Few Words on C# Virtual Methods
Inheritance, Containment, and Delegation
Choosing Between Interface and Class Inheritance
Delegation and Composition vs. Inheritance
Summary
CHAPTER 5: Interfaces and Contracts
Interfaces Define Types
Defining Interfaces
What Can Be in an Interface?
Interface Inheritance and Member Hiding
Implementing Interfaces
Implicit Interface Implementation
Explicit Interface Implementation
Overriding Interface Implementations in Derived Classes
Beware of Side Effects of Value Types Implementing Interfaces
Interface Member Matching Rules
Explicit Interface Implementation with Value Types
Versioning Considerations
Contracts
Contracts Implemented with Classes
Interface Contracts
Choosing Between Interfaces and Classes
Summary
CHAPTER 6: Overloading Operators
Just Because You Can Doesn’t Mean You Should
Types and Formats of Overloaded Operators
Operators Shouldn’t Mutate Their Operands
Does Parameter Order Matter?
Overloading the Addition Operator
Operators That Can Be Overloaded
Comparison Operators
Conversion Operators
Boolean Operators
Summary
CHAPTER 7: Exception Handling and Exception Safety
How the CLR Treats Exceptions
Mechanics of Handling Exceptions in C#
Throwing Exceptions
Changes with Unhandled Exceptions Starting with .NET 2.0
Syntax Overview of the try Statement
Rethrowing Exceptions and Translating Exceptions
Exceptions Thrown in finally Blocks
Exceptions Thrown in Finalizers
Exceptions Thrown in Static Constructors
Who Should Handle Exceptions?
Avoid Using Exceptions to Control Flow
Achieving Exception Neutrality
Basic Structure of Exception-Neutral Code
Constrained Execution Regions
Critical Finalizers and SafeHandle
Creating Custom Exception Classes
Working with Allocated Resources and Exceptions
Providing Rollback Behavior
Summary
CHAPTER 8: Working with Strings
String Overview
String Literals
Format Specifiers and Globalization
Object.ToString, IFormattable, and CultureInfo
Creating and Registering Custom CultureInfo Types
Format Strings
Console.WriteLine and String.Format
Examples of String Formatting in Custom Types
ICustomFormatter
Comparing Strings
Working with Strings from Outside Sources
StringBuilder
Searching Strings with Regular Expressions
Searching with Regular Expressions
Searching and Grouping
Replacing Text with Regex
Regex Creation Options
Summary
CHAPTER 9: Arrays, Collection Types, and Iterators
Introduction to Arrays
Implicitly Typed Arrays
Type Convertibility and Covariance
Sortability and Searchability
Synchronization
Vectors vs. Arrays
Multidimensional Rectangular Arrays
Multidimensional Jagged Arrays
Collection Types
Comparing ICollection with ICollection
Collection Synchronization
Lists
Dictionaries
Sets
System.Collections.ObjectModel
Efficiency
IEnumerable <T>, IEnumerator <T>, IEnumerable, and IEnumerator
Types That Produce Collections
Iterators
Forward, Reverse, and Bidirectional Iterators
Collection Initializers
Summary
CHAPTER 10: Delegates, Anonymous Functions, and Events
Overview of Delegates
Delegate Creation and Use
Single Delegate
Delegate Chaining
Iterating Through Delegate Chains
Unbound (Open Instance) Delegates
Events
Anonymous Methods
Beware the Captured Variable Surprise
Anonymous Methods as Delegate Parameter Binders
The Strategy Pattern
Summary
CHAPTER 11: Generics
Difference Between Generics and C++ Templates
Efficiency and Type Safety of Generics
Generic Type Definitions and Constructed Types
Generic Classes and Structs
Generic Interfaces
Generic Methods
Generic Delegates
Generic Type Conversion
Default Value Expression
Nullable Types
Constructed Types Control Accessibility
Generics and Inheritance
Constraints
Constraints on Nonclass Types
Generic System Collections
Generic System Interfaces
Select Problems and Solutions
Conversion and Operators Within Generic Types
Creating Constructed Types Dynamically
Summary
CHAPTER 12: Threading in C#
Threading in C# and .NET
Starting Threads
The IOU Pattern and Asynchronous Method Calls
States of a Thread
Terminating Threads
Halting Threads and Waking Sleeping Threads
Waiting for a Thread to Exit
Foreground and Background Threads
Thread-Local Storage
How Unmanaged Threads and COM Apartments Fit In
Synchronizing Work Between Threads
Lightweight Synchronization with the Interlocked Class
Monitor Class
Locking Objects
Semaphore
Events
Win32 Synchronization Objects and WaitHandle
Using ThreadPool
Asynchronous Method Calls
Timers
Summary
CHAPTER 13: In Search of C# Canonical Forms
Reference Type Canonical Forms
Default to sealed Classes
Use the Non-Virtual Interface (NVI) Pattern
Is the Object Cloneable?
Is the Object Disposable?
Does the Object Need a Finalizer?
What Does Equality Mean for This Object?
If You Override Equals, Override GetHashCode Too
Does the Object Support Ordering?
Is the Object Formattable?
Is the Object Convertible?
Prefer Type Safety at All Times
Using Immutable Reference Types
Value Type Canonical Forms
Override Equals for Better Performance
Do Values of This Type Support Any Interfaces?
Implement Type-Safe Forms of Interface Members and Derived Methods
Summary
Checklist for Reference Types
Checklist for Value Types
CHAPTER 14: Extension Methods
Introduction to Extension Methods
How Does the Compiler Find Extension Methods?
Under the Covers
Code Readability vs. Code Understandability
Recommendations for Use
Consider Extension Methods Over Inheritance
Isolate Extension Methods in Separate Namespace
Changing a Type’s Contract Can Break Extension Methods
Transforms
Operation Chaining
Custom Iterators
Borrowing from Functional Programming
The Visitor Pattern
Summary
CHAPTER 15: Lambda Expressions
Introduction to Lambda Expressions
Lambda Expressions
Lambda Statements
Expression Trees
Operating on Expressions
Functions As Data
Useful Applications of Lambda Expressions
Iterators and Generators Revisited
Closures (Variable Capture) and Memoization
Currying
Anonymous Recursion
Summary
CHAPTER 16 LINQ: Language Integrated Query
A Bridge to Data
Query Expressions
Extension Methods and Lambda Expressions Revisited
Standard Query Operators
C# Query Keywords
The from Clause and Range Variables
The join Clause
The where Clause and Filters
The orderby Clause
The select Clause and Projection
The let Clause
The group Clause
The into Clause and Continuations
The Virtues of Being Lazy
C# Iterators Foster Laziness
Subverting Laziness
Executing Queries Immediately
Expression Trees Revisited
Techniques from Functional Programming
Custom Standard Query Operators and Lazy Evaluation
Replacing foreach Statements
Summary
APPENDIX References
Blogs
INDEX
Note:
Mindcracker Network accepts no liability for providing the customer with the hard copy of the book purchased. Mindcracker is not responsible for any dispute relating to the above. All eBooks listed in this section are in "PDF" Format. Contact authors@c-sharpcorner.com for further assistant.