Chapter 1:Language Overview 1
Hello,World! 1
Chapter 1:Language Overview 1
1 Language Overview 1
Fundamental Types 3
TABLE 1-1:Fundamental Types 3
TABLE 1-2:Numeric Operators 4
TABLE 1-3:Logical Operators 5
TABLE 1-4:Comparison Operators 5
TABLE 1-5:String Operators 5
TABLE 1-6:Conversion Operators 7
FIGURE 1-1:A One-Dimensional Array 8
Arrays 8
FIGURE 1-2:A Multidimensional Array 9
FIGURE 1-3:An Array of Arrays 10
FIGURE 1-4:A Jagged Array 11
Statements 11
Exception Handling 15
Structured Exception Handling 16
Unstructured Exception Handling 17
Memory Management 17
FIGURE 1-5:A Reference Type Variable and the Heap 18
FIGURE 1-6:A Value Type Variable 19
Classes,Structures,and Modules 19
Accessibility 21
Constructors 21
Nested Types 22
Fields 23
Parameters 24
Methods 24
Declare Statements 26
Properties 28
Events 30
Declarative Event Handling 31
Dynamic Event Handling 31
Namespaces 32
Delegates 34
Inheritance 36
Protected Access 37
Overriding 39
Interfaces 41
Attributes 42
Versioning 44
Conclusion 45
Chapter 2:Basic Concepts 47
2 Basic Concepts 47
Language Fundamentals 47
Case Insensitivity 48
Line Orientation 49
Comments 52
Declarations and Names 53
Forward References 56
Accessibility 57
FIGURE 2-1:The.NET Framework 59
The.NET Framework 59
Program Startup and Termination 60
Conclusion 61
Chapter 3:Fundamental Types 63
3 Fundamental Types 63
Boolean 63
TABLE 3-1:FundamentalTypes 64
Integer Data Types 65
Integer Literals 66
Floating-Point Data Types 68
Floating-Point Literals 69
Decimal Data Type 70
Decimal Literals 71
Char and String Literals 72
Char and String Data Types 72
Date Data Type 73
Date Literals 73
Object Data Type 74
Conversions 76
TABLE 3-2:Conversion Operators 77
Widening and Narrowing Conversions 79
Supported Conversions 80
Conclusion 82
Arrays 85
Chapter 4:Arrays and Enumerations 85
4 Arraysand Enumerations 85
FIGURE 4-1:A One-Dimensional Array 86
ReDim and Erase Statements 86
FIGURE 4-2:A Two-Dimensional Array 87
Array Initializers 89
Arrays of Arrays 90
FIGURE4-3:A Jagged Array 91
Enumerations 92
Underlying Types 93
Conversions 95
Conclusion 97
Chapter 5:Operators 99
Chapter 5:Operators 99
5 Operators 99
Precedence 99
TABLE 5-1:OperatorPrecedence 100
Operator Resolution 101
TABLE 5-2:Arithmetic Operators 103
Arithmetic Operators 103
Comparison Operators 104
TABLE 5-3:Comparison Operators 104
Logical and Bitwise Operators 106
FIGURE 5-1:And Operation 108
Shift Operators 108
FIGURE 5-2:Left and Right Shifting 108
String Operators 109
FIGURE 5-3:Right Shifting with Sign Preservation 109
Type Operators 111
Conclusion 113
Constant Expressions 113
Local Declaration Statements 115
6 Statements 115
Initializers 117
Type Characters 117
Constants 118
Static Locals 119
Implicit Locals 120
Assignment 122
With Statement 123
Conditional Statements 124
If Statement 124
Select Statement 125
Looping Statements 127
For Statement 127
For Each Statement 129
While and Do Statements 131
Collection Types 132
Branching Statements 134
Exit and Return Statements 134
Goto Statement and Labels 135
Program Flow Statements 137
SyncLock 138
Conclusion 140
7 Exceptions 143
Chapter 7:Exceptions 143
Throwing Exceptions 144
TABLE 7-1:Common Exception Types 145
Structured Exception Handling 146
Rethrowing Exceptions 148
Unstructured Exception Handling 149
Resume and Resume Next 152
Conclusions 153
Modules 155
8 Modules and Namespaces 155
Namespaces 157
Fully Qualified Names 160
Imports 161
Preprocessing 164
Conditional Compilation Statements 164
Region Statements 166
Conclusion 167
9 Classes and Structures 169
Memory Management 169
Chapter 9:Classes and Structures 169
FIGURE 9-1:A Reference Type Variable and the Heap 170
The Heap and the Stack 170
Value Types and Structures 171
FIGURE 9-3:An Integer Array 172
FIGURE 9-2:An Integer Variable 172
Reference Types and Classes 173
Shared versus Instance 176
Constructors 178
Structure Constructors 180
Nested Types 181
Shared Constructors 181
Finalization and Resource Disposal 182
Conclusion 185
10 Methods 187
Subroutines and Functions 187
Parameters 188
Optional Parameters and Parameter Arrays 190
Method Invocation 193
Arguments and Reference Parameters 194
Named Arguments 196
Late Binding 196
ConditionalMethods 198
Overloading 199
Overload Resolution 202
Declare Statements 205
Character Translation 207
String Parameters 208
Conclusion 211
11 Fields and Properties 213
Fields 213
Read-Only Fields 214
Properties 216
Indexed Properties 220
Default Properties 223
Dictionary Lookup 224
Conclusion 225
12 Events and Delegates 227
Defining and Raising Events 227
Declarative Event Handling 229
Handling Events Dynamically 231
Delegates 233
Asynchronous Invocation 237
Delegates and Event Implementation 239
Conclusion 243
13 Inheritance 245
Chapter 13:Inheritance 245
Protected Accessibility 248
FIGURE 13-1:An Inheritance Hierarchy 248
Conversions 250
Array Covariance 252
The.NET Framework Type Hierarchy 254
FIGURE 13-2:The.NET Framework Type Hierarchy 255
DirectCast 256
FIGURE 13-3:Boxing an Integer Value 256
FIGURE 13-4:Unboxing an Integer Value 257
Overriding 259
MyBase and MyClass 263
Abstract Classes and Methods 265
Conclusion 268
14 Interfaces 269
Defining Interfaces 270
Implementing Interfaces 271
Private Interface Implementation 273
Event Implementation 275
Consuming Interfaces 277
Interface Inheritance 278
Conclusion 281
Chapter 15:Attributes 283
15 Attributes 283
Applying Attributes 284
Defining Attributes 287
TABLE 15-1:AttributeTargets Values 289
Storing and Reading Attributes 291
Conclusion 293
16 Versioning 295
Shadowing 295
Shadowing and Overriding 298
Shadowing and Accessibility 300
Default Properties 301
Overloading 302
Obsolete 305
Conclusion 306
AppWinStyle Enumeration 307
A Runtime Functions 307
Appendix A:Runtime Functions 307
CallType Enumeration 308
Collection Class 309
ComClassAttribute Attribute 310
CompareMethod Enumeration 311
ControlChars Class 312
Constants Module 312
Conversion Module 313
DateAndTime Module 315
DateFormat Enumeration 319
DateInterval Enumeration 319
DueDate Enumeration 321
ErrObject Class 321
FileAttribute Enumeration 323
FileSystem Module 324
TABLE A-1:FileSystem Equivalents 325
Financial Module 332
FirstDayOfWeek Enumeration 335
FirstWeekOfYear Enumeration 336
Globals Module 336
Information Module 337
Interaction Module 340
MsgBoxResult Enumeration 343
Button Flags 344
MsgBoxStyle Enumeration 344
Icon Flags 345
Miscellaneous Flags 346
Message Box Behavior Flags 346
Default Button Flags 346
OpenMode Enumeration 347
OpenAccess Enumeration 347
OpenShare Enumeration 348
Strings Module 349
Format Strings 356
TABLE A-2:Numeric Predefined Formats 356
TABLE A-3:Date/Time Predefined Formats 357
TABLE A-5:Numeric User-Defined Format Characters 358
TABLE A-4:Other Predefined Formats 358
TABLE A-6:Date/Time User-Defined Format Characters 359
TriState Enumeration 361
VariantType Enumeration 362
VbStrConv Enumeration 364
VBMath Module 366
VBFixedArrayAttribute Attribute 367
VBFixedStringAttribute Attribute 368
Classes 369
Type System Additions 369
B Making the Transition from COM to the CLR 369
Inheritance 372
Overloading 376
Arrays 378
Type System Modifications 378
Namespaces 378
Variant and Object 380
Structures 383
Date,Currency,and Decimal 384
Platform Changes 385
Deterministic Finalization and Garbage Collection 385
Let and Set Assignment 387
Late Binding 389
On Error and Structured Exception Handling 390
Events and Delegates 394
Language Cleanup 396
Index 399