xvi
CONTENTS
usinG arrays and ColleCtions 19lesson 16: 5
Arrays 195
Creating Arrays 196
Multi-Dimensional Arrays 198
Array Properties and Methods 199
Collection Classes 200
Generic Classes 200
Lists 201
SortedLists 202
Dictionaries 203
Queues 203
Stacks 204
Try It 204
Lesson Requirements 205
Step-by-Step 205
Exercises 206
usinG enuMerations and struCtures 20lesson 17: 9
Enumerations 209
Structures 210
Structures Versus Classes 211
Try It 212
Lesson Requirements 213
Step-by-Step 213
Exercises 215
proGraM stateMentseCtion iii: s
MakinG ChoiCes 21lesson 18: 9
Decision Statements 219
If Statements 220
If-Else 220
Cascading If Statements 221
Nested If Statements 222
Switch Statements 223
Try It 225
Lesson Requirements 225
Hints 225
Step-by-Step 225
Exercises 226
596906ftoc.indd 16 4/7/10 12:31:12 PM
xvii
CONTENTS
repeatinG proGraM steps 22lesson 19: 9
For Loops 229
Foreach Loops 231
While Loops 232
Do Loops 233
Break and Continue 235
Try It 236
Lesson Requirements 236
Hints 237
Step-by-Step 237
Exercises 238
reusinG Code with Methods 24lesson 20: 1
Method Advantages 241
Method Syntax 242
Parameters by Reference 245
Try It 246
Lesson Requirements 247
Hints 247
Step-by-Step 247
Exercises 249
handlinG errors 25lesson 21: 1
Errors and Exceptions 251
Try-Catch Blocks 252
Throwing Errors 254
Try It 255
Lesson Requirements 256
Hints 256
Step-by-Step 256
Exercises 258
preVentinG BuGs 25lesson 22: 9
Input Assertions 259
Other Assertions 262
Try It 262
Lesson Requirements 263
Hints 263
Step-by-Step 263
Exercises 265
596906ftoc.indd 17 4/7/10 12:31:13 PM
xviii
CONTENTS
ClasseseCtion iV: s
deFininG Classes 26lesson 23: 9
What Is a Class? 269
Class Benefits 270
Making a Class 271
Properties 271
Try It 274
Lesson Requirements 274
Hints 275
Step-by-Step 275
Methods 276
Events 276
Delegates 276
Event Handler Delegates 278
Try It 280
Lesson Requirements 281
Hints 281
Step-by-Step 281
Inheritance 283
Polymorphism 284
Try It 284
Lesson Requirements 285
Hints 285
Step-by-Step 285
Exercises 288
initializinG oBjeCts 28lesson 24: 9
Initializing Objects 289
Constructors 290
Parameterless Constructors 290
Parameterized Constructors 291
Destructors 292
Invoking Other Constructors 294
Try It 296
Lesson Requirements 296
Hints 296
Step-by-Step 296
Exercises 300
596906ftoc.indd 18 4/7/10 12:31:13 PM
xix
CONTENTS
Fine-tuninG Classes 30lesson 25: 1
Overloading Methods 301
Overriding Methods 302
Try It 305
Lesson Requirements 305
Hints 306
Step-by-Step 306
Exercises 310
oVerloadinG operators 31lesson 26: 1
Overloadable Operators 311
Unary Operators 312
Binary Operators 313
Comparison Operators 314
Try It 314
Lesson Requirements 314
Hints 315
Step-by-Step 315
Exercises 318
usinG interFaCes 31lesson 27: 9
Interface Advantages 319
Multiple Inheritance 319
Code Generalization 320
Implementing Interfaces 321
Defining Interfaces 324
Try It 324
Lesson Requirements 325
Hints 325
Step-by-Step 325
Exercises 327
MakinG GeneriC Classes 33lesson 28: 1
Defining Generic Classes 331
Using Generic Constraints 333
Making Generic Methods 334
Try It 335
Lesson Requirements 336
Hints 336
Step-by-Step 336
Exercises 338
596906ftoc.indd 19 4/7/10 12:31:13 PM
xx
CONTENTS
systeM interaCtionseCtion V: s
readinG and writinG Files 34lesson 29: 3
Understanding Streams 343
Writing Files 344
Reading Files 345
Try It 346
Lesson Requirements 346
Hints 346
Step-by-Step 346
Exercises 347
usinG File systeM Classes 34lesson 30: 9
The DriveInfo Class 349
The DirectoryInfo Class 351
The Directory Class 352
The FileInfo Class 353
The File Class 354
The Path Class 355
Try It 356
Lesson Requirements 356
Hints 356
Step-by-Step 357
Exercises 358
printinG 35lesson 31: 9
Basic Printing 359
Drawing Shapes 360
Drawing Text 363
Try It 364
Lesson Requirements 364
Hints 365
Step-by-Step 365
Exercises 367
usinG the ClipBoard 36lesson 32: 9
Adding Data to the Clipboard 369
Getting Data from the Clipboard 371
596906ftoc.indd 20 4/7/10 12:31:13 PM

Get Stephens' C# Programming with Visual Studio® 2010 24-Hour Trainer now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.