| Introduction | xxv |
| PART I THE BASICS | |
| 1 Getting Started with Visual Basic .NET | 3 |
| Why .NET? | 3 |
| Issues with Today's Software Development | 3 |
| The Solution According to Microsoft .NET | 9 |
| The Microsoft .NET Project | 16 |
| Requirements | 16 |
| .NET Architecture | 17 |
| .NET Languages | 20 |
| Microsoft Intermediate Language (MSIL) | 27 |
| The Just-in-Time (JIT) Compiler | 30 |
| Working with Assemblies | 35 |
| The .NET Framework Class Library | 41 |
| Introduction to Visual Studio .NET | 48 |
| Old and Renewed Tools | 48 |
| New Tools | 60 |
| Running a Visual Basic Console Application | 69 |
| 2 Modules and Variables | 73 |
| Modules and Namespaces | 73 |
| Modules | 74 |
| Classes | 77 |
| Forms | 79 |
| Namespaces | 80 |
| Variables | 87 |
| Declarations | 87 |
| Data Types | 92 |
| Initializers | 98 |
| Assignments | 100 |
| Arrays | 111 |
| Structures | 115 |
| 3 Control Flow and Error Handling | 119 |
| Execution Flow Control | 119 |
| Procedures | 119 |
| Conditional and Loop Statements | 126 |
| The Declare Statement | 130 |
| Commands, Functions, and Constants | 131 |
| String Constants | 131 |
| String Functions | 132 |
| Math Functions | 132 |
| Date and Time Functions | 133 |
| Interaction Commands and Functions | 134 |
| Other Commands, Functions, and Objects | 135 |
| The Environment Class | 136 |
| Error Handling | 138 |
| Throwing Exceptions | 138 |
| The Exception Object | 140 |
| The Try...Catch...Finally Statement | 142 |
| The Throw Statement | 149 |
| Nested Exception Objects | 154 |
| Performance Tips | 156 |
| Debugging .NET Applications | 158 |
| Project and Solution Configurations | 158 |
| Debugging Tools | 160 |
| Tracing Application Behavior | 164 |
| PART II OBJECT-ORIENTED PROGRAMMING | |
| 4 Class Fundamentals | 175 |
| Fields | 175 |
| Methods | 179 |
| Overloading | 179 |
| Overloading and Coercion | 182 |
| Ambiguous Cases | 183 |
| Properties | 184 |
| Read-Only and Write-Only Properties | 186 |
| Properties with Arguments | 188 |
| Default Properties | 189 |
| Constructors | 190 |
| Constructors with Arguments | 190 |
| Overloaded Constructors | 193 |
| Constructors and Read-Only Fields | 195 |
| Object Lifetime | 196 |
| COM and the Reference Counter | 196 |
| Garbage Collection | 197 |
| The Finalize Method | 198 |
| The Dispose Method | 201 |
| Object Resurrection | 206 |
| Generations | 210 |
| Garbage Collection and Threading | 213 |
| Weak Object References | 214 |
| Events | 216 |
| Declaring and Raising an Event | 216 |
| Trapping Events with WithEvents | 217 |
| Trapping Events with AddHandler | 218 |
| Module Events | 222 |
| Trapping Events from Arrays | 223 |
| Guidelines for Event Syntax | 224 |
| Shared Members | 227 |
| Shared Fields | 227 |
| Shared Methods | 229 |
| Shared Constructors | 232 |
| Shared Events | 234 |
| 5 Inheritance | 237 |
| Inheritance in Previous Visual Basic Versions | 237 |
| Inheritance by Delegation | 238 |
| Inheritance and Late-Bound Polymorphic Code | 238 |
| Early-Bound Polymorphic Code | 239 |
| Inheritance in Visual Basic .NET | 240 |
| Extending the Derived Class | 241 |
| Using the Derived Class | 241 |
| Inheriting Events | 243 |
| Inheriting Shared Members | 243 |
| Polymorphic Behavior | 244 |
| Overriding Members in the Base Class | 245 |
| Override Variations | 247 |
| The MyBase Keyword | 248 |
| Constructors in Derived Classes | 249 |
| Finalizers in Derived Classes | 251 |
| The MyClass Keyword | 252 |
| Member Shadowing | 255 |
| Redefining Shared Members | 259 |
| Sealed and Virtual Classes | 260 |
| The NotInheritable Keyword | 260 |
| The MustInherit Keyword | 261 |
| The MustOverride Keyword | 262 |
| Scope | 264 |
| Nested Classes | 264 |
| Public, Private, and Friend Scope Qualifiers | 267 |
| The Protected Scope Qualifier | 268 |
| The Protected Friend Scope Qualifier | 271 |
| Using Scope Qualifiers with Constructors | 272 |
| Redefining Events | 275 |
| 6 Interfaces and Delegates | 279 |
| Interfaces | 279 |
| Implementing the Interface | 281 |
| Accessing the Interface | 284 |
| Interfaces and Inheritance | 285 |
| Using .NET Interfaces | 286 |
| The IComparable Interface | 287 |
| The IComparer Interface | 288 |
| The ICloneable Interface | 291 |
| The IEnumerable and IEnumerator Interfaces | 294 |
| Delegates | 303 |
| Invoking Static Methods | 303 |
| Invoking Instance Methods | 306 |
| Other Properties | 307 |
| Defining Polymorphic Behavior | 307 |
| Delegates and Windows API Callbacks | 309 |
| Implementing Callback Procedures | 311 |
| Multicast Delegates | 312 |
| 7 Attributes | 317 |
| Attribute Syntax | 318 |
| Attributes for Visual Basic .NET | 319 |
| The StructLayout Attribute | 319 |
| The FieldOffset Attribute | 321 |
| The DllImport Attribute | 324 |
| The Conditional Attribute | 326 |
| The Obsolete Attribute | 328 |
| The DebuggerStepThrough Attribute | 328 |
| Custom Attributes | 329 |
| Building a Custom Attribute Class | 329 |
| Discovering Attributes at Run Time | 331 |
| PART III PROGRAMMING THE .NET FRAMEWORK | |
| 8 .NET Framework Basic Types | 337 |
| The System.Object Type | 337 |
| Public and Protected Methods | 338 |
| Value Types and Reference Types (Revisited) | 340 |
| Boxing and Unboxing | 341 |
| The String Type | 343 |
| Properties and Methods | 344 |
| String Optimizations | 348 |
| Shared Methods | 350 |
| The CultureInfo Auxiliary Class | 351 |
| Formatting Numeric Values | 353 |
| Formatting Date Values | 357 |
| The IFormattable Interface | 359 |
| The IFormatProvider and ICustomFormatter Interfaces | 361 |
| The Char Type | 363 |
| The StringBuilder Type | 363 |
| Numeric Types | 366 |
| Properties and Methods | 366 |
| Formatting Numbers | 368 |
| Parsing Strings into Numbers | 369 |
| The Convert Class | 370 |
| Random Number Generators | 371 |
| The DateTime Type | 372 |
| Adding and Subtracting Dates | 373 |
| Formatting Dates | 375 |
| Parsing Dates | 376 |
| Working with Time Zones | 377 |
| The Guid Type | 378 |
| Enums | 379 |
| Displaying and Parsing Enum Values | 380 |
| Other Enum Methods | 381 |
| Bit-Coded Values | 382 |
| 9 Arrays, Lists, and Collections | 385 |
| The Array Class | 385 |
| Creating Nonzero-Based Arrays | 387 |
| Copying Arrays | 388 |
| Sorting Elements | 389 |
| Clearing, Copying, and Moving Elements | 391 |
| Searching Values | 393 |
| Arrays of Arrays | 395 |
| The System.Collections Namespace | 396 |
| The ICollection, IList, and IDictionary Interfaces | 396 |
| The BitArray Class | 398 |
| The Stack Class | 400 |
| The Queue Class | 400 |
| The ArrayList Class | 402 |
| The Hashtable Class | 405 |
| The SortedList Class | 408 |
| The StringCollection and StringDictionary Classes | 411 |
| Custom Collection and Dictionary Classes | 413 |
| The ReadOnlyCollectionBase Abstract Class | 413 |
| The CollectionBase Abstract Class | 414 |
| The DictionaryBase Abstract Class | 417 |
| 10 Files, Directories, and Streams | 419 |
| The Directory and File Classes | 420 |
| The DirectoryInfo and FileInfo Classes | 425 |
| The Path Class | 428 |
| The Stream Class | 429 |
| Stream Operations | 429 |
| Stream Readers and Writers | 430 |
| Reading and Writing Text Files | 431 |
| Reading and Writing Binary Files | 434 |
| Reading and Writing Memory Streams | 435 |
| Reading and Writing Strings in Memory | 437 |
| Custom Stream Readers and Writers | 437 |
| 11 Object Serialization | 441 |
| Basic Serialization | 441 |
| Binary Serialization | 442 |
| SOAP Serialization | 443 |
| The Serializable and NonSerialized Attributes | 446 |
| Object Graphs | 447 |
| Deep Object Cloning | 450 |
| Custom Serialization | 452 |
| The ISerializable Interface | 452 |
| A Custom Serialization Example | 453 |
| The StreamingContext Structure | 455 |
| The IDeserializationCallback Interface | 457 |
| XML Serialization | 460 |
| The XmlSerializer Class | 461 |
| Serialization Attributes | 462 |
| The XmlSerializerNamespaces Object | 467 |
| Deserialization Events | 468 |
| Overriding Behavior | 469 |
| Working with XSD Schemas | 476 |
| 12 Regular Expressions | 481 |
| Regular Expression Overview | 482 |
| The Fundamentals | 482 |
| The Regular Expression Language | 484 |
| Regular Expression Options | 490 |
| Regular Expression Classes | 493 |
| The Regex Class | 493 |
| The MatchCollection and Match Classes | 499 |
| The Group Class | 500 |
| The CaptureCollection and Capture Classes | 502 |
| Regular Expressions at Work | 504 |
| 13 Threading | 511 |
| Threading Fundamentals | 511 |
| When to Use Threads | 512 |
| Creating Threads | 513 |
| Working with Threads | 514 |
| Thread Properties | 517 |
| Debugging Threads | 519 |
| Storing and Sharing Data | 521 |
| Local, Class, and Static Variables | 522 |
| The ThreadStatic Attribute | 523 |
| Thread Local Storage | 524 |
| Passing Data to and from a Thread | 525 |
| Using a Wrapper Class | 529 |
| Thread Synchronization | 532 |
| The SyncLock Statement | 532 |
| Synchronized Objects | 534 |
| The Monitor Class | 536 |
| The Interlocked Class | 539 |
| The Mutex Class | 540 |
| The ReaderWriterLock Class | 541 |
| The ManualResetEvent and AutoResetEvent Classes | 543 |
| The ThreadPool Class | 546 |
| Timers | 548 |
| The System.Timers.Timer Class | 548 |
| The System.Threading.Timer Class | 549 |
| Asynchronous Operations | 551 |
| Asynchronous Delegates | 552 |
| Asynchronous File Operations | 559 |
| 14 Assemblies and AppDomains | 563 |
| Modules | 563 |
| Headers | 564 |
| Metadata | 564 |
| Microsoft Intermediate Language (MSIL) | 565 |
| Assemblies | 568 |
| Single-File and Multiple-File Assemblies | 568 |
| The Manifest | 569 |
| Private and Shared Assemblies | 570 |
| Strong Names | 574 |
| Partial Signing and Key Containers | 576 |
| The Binding Process | 577 |
| Version Policy in Application Configuration Files | 578 |
| Previously Loaded Assemblies and GAC Searches | 581 |
| Codebase Hints | 581 |
| Probing | 582 |
| The Assembly Binding Log Viewer Utility (FUSLOGVW) | 585 |
| A Real Example | 586 |
| Configuration Files | 595 |
| Runtime Version | 596 |
| Garbage Collection Behavior | 596 |
| Dynamic Properties | 597 |
| The .NET Framework Configuration Tool | 598 |
| Command-Line Tools | 601 |
| The Visual Basic Compiler (VBC) | 602 |
| The Assembly Linker (AL) | 606 |
| The Strong Name Utility (SN) | 610 |
| The Global Assembly Cache Utility (GACUTIL) | 611 |
| The MSIL Disassembler (ILDASM) | 612 |
| The Native Image Generator Utility (NGEN) | 615 |
| Assembly Custom Attributes | 617 |
| The AssemblyInfo.vb File | 617 |
| The AppDomain Class | 619 |
| Properties, Methods, and Events | 619 |
| Creating AppDomains | 623 |
| Catching Unhandled Exceptions | 625 |
| The LoaderOptimization Attribute | 629 |
| 15 Reflection | 631 |
| Working with Assemblies and Modules | 632 |
| The Assembly Class | 632 |
| The AssemblyName Class | 635 |
| The Module Class | 637 |
| Working with Types | 638 |
| Getting a Type Object | 638 |
| Retrieving Type Attributes | 640 |
| Enumerating Members | 643 |
| Retrieving Member Information | 650 |
| Enumerating Parameters | 655 |
| Invoking Members | 656 |
| Creating an Object Dynamically | 660 |
| Security Issues | 661 |
| Reflection Examples | 662 |
| A Command-Line Type Browser | 662 |
| Tracing the Stack Frame | 668 |