Table of Contents
■
CHAPTER 1: VB 2005 Overview
Differences Between VB 2005, C#, and VB6
.NET Runtime
VB 2005 and C#
VB 2005 and VB6
CLR Garbage Collection
Common Type System
A Simple VB 2005 Program
What’s New in VB 2005
New Commands
Generics
Operator Overloading
My Namespace
Summary
■
CHAPTER 2: VB 2005 and the CLR
From VB to IL
From IL to Platform
Understanding Assemblies
Assembly Management
Private Assemblies
Shared Assemblies
Loading Assemblies
Cross-Language Compatibility
Metadata: Better Than COM
Summary
■
CHAPTER 3: VB Syntax
Types and Variables
Strong Typing
Type Categories
Value Types
Reference Types
Type Conversion
Namespaces
Defining Namespaces
Using Namespaces
Statements
Control Flow Constructs
If...Then...Else
Select...Case
Iteration and Looping Constructs
For Each...Next
For...Next
Do While and Do Until
Continue
Summary
■
CHAPTER 4: Classes and Structures
Class Definitions
Constructors
Accessibility
Interfaces
MyBase and MyClass Keywords
NotInheritable Classes
MustInherit Classes
Nested Classes
Item Property Indexers
Partial Classes
Value Type Definitions
Constructors
The Meaning of Me
Finalizers
Interfaces
Boxing and Unboxing
When Boxing Occurs
Efficiency and Confusion
System.Object
Equality and What It Means
The IComparable Interface
Creating Objects
The New Keyword
Shared Constructor
Instance Constructor and Creation Ordering
Destroying Objects
Finalizers
Exception Handling
Disposable Objects
The IDisposable Interface
The Using Keyword
Summary
■
CHAPTER 5: Methods, Properties, and Fields
Methods
Shared Methods
Instance Methods
Method Parameter Types
Method Overloading
Overridable and MustOverride Methods
A Final Few Words on Overridable Methods
Properties
Accessors
Declaring Properties
Fields
Summary
■
CHAPTER 6: Inheritance, Polymorphism, and Encapsulation
Inheritance
Accessibility of Members
Implicit Conversion and a Taste of Polymorphism
Member Hiding
Inheritance, Containment, and Delegation
Choosing Between Interface and Class Inheritance
Delegation and Composition vs. Inheritance
Encapsulation
Summary
■
CHAPTER 7: Interfaces
Interfaces Are Reference Types
Defining Interfaces
What Can Be in an Interface?
Interface Inheritance
Implementing Multiple Interfaces
Hiding Interface Members
Implementing Interfaces in Structures
Beware of Side Effects of Value Types Implementing Interfaces
Using Generics with Interfaces
Using a Generic Interface
Using a Generic Method in an Interface
Contracts
Implementing Contracts with Classes
Implementing Contracts with Interfaces
Choosing Between Interfaces and Classes
Polymorphism with Interfaces
Summary
■
CHAPTER 8: Operator Overloading
Just Because You Can Doesn’t Mean You Should
Operators That Can Be Overloaded
Types and Formats of Overloaded Operators
Operators Shouldn’t Mutate Their Operands
Does Parameter Order Matter?
Overloading the Addition Operator
Comparison Operators
Conversion Operators
Boolean Operators.
Summary
■
CHAPTER 9: Exception Handling
Handling Exceptions
Avoid Using Exceptions to Control Flow
Mechanics of Handling Exceptions in VB 2005
Throwing Exceptions
Unhandled Exceptions in .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
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 10: 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 11: Arrays and Collections
Introduction to Arrays
Type Convertibility and Covariance
Sortability and Searchability
Synchronization
Multidimensional Arrays
Multidimensional Jagged Arrays
Collection Types
Comparing ICollection(Of T) with ICollection
Collection Synchronization
Types That Produce Collections
Lists
Dictionaries
System.Collections.ObjectModel
How Iteration Works
Summary
■
CHAPTER 12: Delegates and Events
Overview of Delegates
Delegate Creation and Use
Single Delegate
Delegate Chaining
Iterating Through Delegate Chains
Open-Instance Delegates
Strategy Pattern
Events
Summary
■
CHAPTER 13: Generics
Introduction to Generics
Efficiency and Type Safety of Generics
Generic Type Placeholder Naming Conventions
Generic Type Definitions and Constructed Types
Generic Classes and Structures
Generic Interfaces
Generic Methods
Generic Delegates
Generic Type Conversion
Nullable Types
Constructed Types Control Accessibility
Constraints
Constraints on Nonclass Types
Generic System Collections
Select Problems and Solutions
Conversion and Operators Within Generic Types
Creating Constructed Types Dynamically
Summary
■
CHAPTER 14: Threading
Threading in VB 2005 and .NET
Starting Threads
The IOU Pattern and Asynchronous Method Calls
States of a Thread
Terminating Threads
Halting and Waking Threads
Waiting for a Thread to Exit
Foreground and Background Threads
Thread-Local Storage
Synchronizing Threads
Lightweight Synchronization with the Interlocked Class
Monitor Class
Locking Objects
Events
Win32 Synchronization Objects and WaitHandle
Using the ThreadPool
Asynchronous Method Calls
Timers
Summary
■
CHAPTER 15: Canonical Forms
Reference-Type Canonical Forms
Default to NotInheritable Classes
Use the 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()
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
Design Checklists
Checklist for Reference Types
Checklist for Value Types
Summary