Training
Certifications
Books
Special Offers
Community




 
OOP with Microsoft® Visual Basic® .NET and Microsoft Visual C#™ .NET Step by Step
Author Robin A. Reynolds-Haertle
Pages 416
Disk 1 Companion CD(s)
Level All Levels
Published 01/23/2002
ISBN 9780735615687
ISBN-10 0-7356-1568-3
Price(USD) $39.99
To see this book's discounted price, select a reseller below.
 

More Information

About the Book
Table of Contents
Sample Chapter
Index
Related Series
Related Books
About the Author

Support: Book & CD

Rate this book
Barnes Noble Amazon Quantum Books

 

Index


Symbols and Numbers
/// <summary> comments, 49
+ (addition operator), overloading, 323
== (equals operator), overloading, 321-322, 330
* (multiplication operator), overloading, 324
!= (not equals operator), overloading, 321-322
; (semicolon), 32

A
abstract base classes, creating, 292
abstract classes
   base class creation, 292
   collection classes, 152-156
   creating, 141-144, 161
   defined, 137-138
   derived classes, creating, 144-149, 161
   diagramming with UML, 139-141
   inherited abstract members, 146-147
   methods, 139, 144, 161
   Must keyword, 141
   MustInherit keyword, 272
   MustOverride keyword, 143
   Pattern class example, 271-272
   properties, 139, 143, 161
abstract collection classes, 152-156
abstract methods, 139, 144, 161
abstract properties, 139, 143, 161
abstraction, 73
Access, Microsoft, DataSet creation for, 351-356
accessors, 9
ACM (Association for Computing Machinery), 378
Add Class command, Project menu, 5, 17
AddHandler statements, 184-185
addition operator (+), overloading, 323
addition, vector, 318
ADO.NET
   DataAdapters, 349
   DataColumns, 351
   DataConnections, 349
   DataRows, 351
   DataSets defined, 348-349
   DataTables, 349, 351, 355
   defined, 348
   filling a database, 352-354
   SQL for defining DataSets, 352
   typed DataSet creation, 351-356
   untyped DataSet creation, 350-351
aggregation, 200
AllowDrop property, 93
ApplicationException class, 190, 194-195
ArrayLists
   adding objects to, 61
   disadvantages of, 151
   shared or static, 302
arrays
   ArrayLists. See ArrayLists
   of class instances, 69
   creating, 36
   declaring, 38, 40
   of enumeration values, 215
   of object instances, 35-36, 41
   out-of-range exceptions, 188
   of references, 40, 41
   returned by properties, 366
as keyword, 127
Assembly class, 303-307
assignment operators, 320
Association for Computing Machinery (ACM), 378
attributes
   adding to properties, 235
   importing from a namespace, 204-205
   purpose of, 174
AutoScroll property, 93

B
BackColor property, 93
banking example
   abstract classes using, 139-144
   account creation, 123-124
   base class creation, 107-111
   CheckingAccount class creation, 119-122, 147-149
   interface for BankAccount, 109-110
   members of BankAccount class, 107
   overriding properties, 114-116
   purpose of, 106-107
   RoundButton class creation, 127-131
   SavingsAccount class creation, 111-119, 144-147
   testing abstract classes, 149-151
   testing CheckingAccount class, 121-122
   testing SavingsAccount class, 118-119
   totals, 142-143
   user interface creation, 123
base classes
   abstract. See abstract classes
   base keyword, 116-117, 121, 133
   base references to, 292
   C# Class Wizard tab, 18
   calling constructors, 133
   creating, banking example, 107-111
   declarations indicating, 111, 133
   defined, 106
   design considerations, 269
   MyBase keyword, 116-117
   overriding properties, 114-116, 134
   preventing classes from becoming, 161
   preventing instantiation. See abstract classes
   pulling up fields to, 368-372
   references to instances, 126
   single inheritance, 132
   Task List messages regarding, 112
   virtual properties, 112
base keyword, 116-117, 121, 133
BetterCard project, 303-309
binary operators, overloading, 323-324, 330
binary serialization. See also serialization
   defined, 332-333
   defining, 340-342
   implementing, 342-344
binary serialization example
   Add method, 336
   BinaryFormatter class, 342-343
   data class creation, 333-337
   defining of serialization, 340-342
   Remove method, 336
   testing, 344
   ToArray method, 336-337
   ToString method, overriding, 334-336
   Triangle class, 333-337
   user interface, 332, 337-340
   XML serialization, 344-347
BinaryFormatter class, 342-343
bitmaps. See also graphics; icons
   assigning, 235
   BitmapPattern class creation, 280-282
   BitmapPatternEditor class creation, 282-285
Book Reader example
   Book class creation, 5-12
   class design, 2-4
   constructors for implementing, 30-36
   instantiation of Book class, 12-16
   Library class creation, 17-22
   ListBox control for, 37
   typed collection classes for, 151-158
   user interface creation, 22-25
browsing file structures, code for, 55-57, 66-67
Build Action properties, Embedded Resources, 203, 221, 303
building. See testing
buttons
   adding to forms, 130
   AllowDrop property, 93
   ButtonBase class, finding, 129
   Click event method, coding, 13-14
   creating at run time, 96-98, 103
   deriving by inheritance, 127-131
   drag-and-drop behavior, creating, 99-101, 103
   FlatStyle property, 98
   image properties, setting, 98
   RoundButton class creation, 127-131
   setting properties of, 13-14

C
C# Add Method Wizard, 20-22
C# Class Wizard
   base class indication, 112
   creating classes, 17-18
C# Field Wizard, 19-20
C# Property Wizard, 49
camel Casing, 360-361, 375
capitalization of names, 7, 360-367, 375
Card class
   playing cards example, 74-77
   shared or static Sorted List example, 302-309
cards, playing, example. See playing cards example
case statements, substituting inheritance for, 132
casing of names, 7, 360-367, 375
casting. See also conversion
   collection classes, 78
   defined, 21
   delegates, 328, 330
   eliminating with typed collection classes, 153
   interface members, 244-245
   System.object, 125
catching exceptions, 187. See also exceptions
CheckedListBox collections, 338-339
circles, drawing, 129
class libraries
   adding controls, 202
   application projects for, 210
   attribute importation, 204-205
   building, 232
   creation, 235
   namespace, naming, 201
   .NET guidelines for, 360
   project creation, 201
   references to, adding, 210
   testing classes in, 209
   Toolbox icons for, 203
   Windows Control Library selection, 201
Class View, 16-17, 113
classes
   abstract. See abstract classes
   abstraction, 73
   base. See base classes
   casing, 363
   Class View, 16-17
   client code design, 73
   compositions, 106
   containment, 73
   creating with Add Class command, 5-7, 26
   creating with C# Class Wizard, 17-18
   declaring, syntax, 6
   definitions, locating, 7
   definitions, structure for organizing, 12
   derived, 106
   design, testing for functionality, 4
   designing for reuse, 73
   diagramming with UML, 139-141
   Dispose method for releasing instances, 217
   eliminating candidates, rules for, 3
   fields in. See fields
   identifying during design, 3
   identity concept, 15
   implementing interfaces, 265
   inheriting from. See base classes; inheritance
   inner, 252-253
   instantiating, 12-16, 27
   interfaces for, 73
   interfaces, implementing, 240-243, 247-249
   Main methods, 83-85
   members, guidelines for, 363-367
   methods of. See methods
   naming, 363
   NonInheritable keyword, 159, 161
   prefixes, 363
   releasing instances, 217
   sealed, 159, 161
   shared, 309-313
   static, 309-313
   testing components, 83
   testing with drivers, 13
   typed collection, 152-158
Click event
   associating methods with, 185
   coding for Browse button, 66-67
   method, coding, 13-14
Clipboard, 332
code analysis project. See also SourceFile class, designing
   CodeAnalysis2, 58-67
   displaying classes, 65-66
   object of, 44-45
   testing, 67
collection editors, 212
collections
   abstract classes, 152-156
   casting, 78
   CheckedListBox, 338-339
   defining arrays of enumerations for, 214-215
   ListBox controls collection editor, 198
   typed collection classes, 152-158
colors
   BackColor property, 93
   intensity of, representing with, 249-250
ComboBox controls, 124-125
CompareTo method, 246-248
comparisons. See IComparable interface
compiling. See testing
component trays, adding components to, 220
ComponentModel namespace, 305
components
   adding to toolboxes, 219
   creating, 235
   Deck component, creating, 212-213
   hosting in containers, 213
   hosting other components, 213
   IComponent interface, 245
   icons, assigning to, 235
   toolboxes, adding to, 235
composition relationships, 106, 164, 200
Computer Society, IEEE, 378
concrete classes, 273
connections, database, 349, 352
console applications
   creating, 239
   start-up methods, 244-245
const keyword, 168
constants, 168
constructors
   adding to classes, 32-33, 41
   base class, calling, 133
   creating instances of classes with, 35-36
   creating with parameters, 32-33, 41
   creation, SourceFile class example, 52-54
   defined, 7, 29-30
   of events, 172
   of exceptions, 190-191
   exceptions in, 33
   parameterless, creating, 52
   parameters, adding, 52
   public keyword with, 30
   shared, 302-307, 315
   Singleton design pattern, 310
   static, 302-307, 315
   syntax for declaring, 30
   validating data, 34
containment, 73, 263-264
Control base class, 169
controls
   adding to forms, 22-23
   adding to projects, 221
   AllowDrop property, 93
   BackColor property, 93
   base class, overriding methods, 169
   buttons. See buttons
   CheckedListBox collections, 338-339
   ComboBox controls, 124-125
   converting values to object instances, 327
   creating at run time, 96-98, 103
   custom. See UserControl class
   deleting during run time, 96-98
   drag-and-drop behavior, creating, 103
   event declarations, 226
   Height, setting, 169
   icon definition for, 221
   inheriting from, 127-131
   initializing, 206-207
   Label, 23
   ListBoxes. See ListBox controls
   multiple, single method for events, 328-330
   NumericUpDown, 22-23, 325-327
   override code, adding, 276, 280
   placing on forms, 64-65
   properties, adding to, 221-223
   RichTextBox, 23
   run time manipulation of, 96-98, 103
   Saved event, adding to, 276, 280, 285
   scrolling in, 93
   size, preventing changes to, 208-209
   SizeChanged events, 208-209
   Timer, 174-175, 179-180
   toolboxes, adding to, 210-211, 232, 235
   TrackBar, 181-183
   user. See UserControl class
conversion, 37. See also casting
currency
   decimal data type, 108
   String.Format method, 110

D
data, saving. See saving data
data types
   checking regarding inheritance, 132
   decimal, 108, 258
   finding for an object, 126-127
   prefixes indicating, 362-363
   reference, 38-39
   value, 39
data views, 264-265
databases. See DataSets
DataError controls, 245
DataGrid controls
   arrays of class instances as data sources, 69
   data sources, setting, 55
   determining DataSet used, 353
   filling from a database, 352
   using in design, 45-46
DataSets
   casting by typed, 355-356
   class declarations, 354
   creating untyped, 350-351, 357
   creation from databases, 352, 357
   DataAdapters, 349
   DataColumns, 351
   DataConnections, 349
   DataMember property, 351, 353
   DataRows, 351
   DataTables, 349, 351, 355
   defined, 348-349
   displaying in Solution Explorer, 354
   files defining, 354
   filling a database, 352-354
   SQL for defining, 352
   typed vs. untyped, 353-354
   typing, 349, 351-357
   untyped, creating, 350-351, 357
   user interface for example, 349
decimal data type, 108, 258
Default keyword, 63
default properties, creating, 63, 78. See also indexers
delegates
   adding to data structures, 328, 330
   calling events with, 328, 330
   casting, 328, 330
   declaring in controls, 226
   design considerations, 366
   event, 173, 176, 180, 186-187
   instancing, 328
   SavedEventHandler, 273
   VectorMath, 327-329
delegation, 263-264
derived classes
   abstract classes, based on, 144-149
   assigning instances to base class reference variables, 292
   CheckingAccount class example, 119-122
   constructors for, 116-117
   declarations indicating, 133, 292
   defined, 106
   Inherits keyword, 144
   overriding properties, 114-116
   polymorphism, using, 122
   properties, redefining, 112
   public members of, 273
   SavingsAccount example, 111-119
   Task List messages regarding, 112
   UML for, 270
deserialization
   defined, 331
   Deserialize method, 343, 357
   XML deserialization, 345-347
design considerations
   case insensitivity, 362
   classes, 2-4, 363
   complexity, reducing, 359
   delegates, 366
   events, 366-367
   interfaces, 363-364
   members of classes, 363-367
   methods, 364
   naming objects, 360-367
   .NET guidelines, 360-367
   patterns. See design patterns
   prefixes, 362-363
   properties, 365-366
   refactoring, 368-372
   shared and static members, 314
   UML for. See UML
design patterns
   defined, 309, 372
   elements of, 373
   Observer, 373-374
   publish-subscribe, 373-374
   reference for, 377
   Singleton pattern, 309-313
Designer command, View menu, 169
DictionaryBase class, 152, 154
directories, browsing, code for, 55-57
Dispose method, 217
documentation. See XML documentation
double values, 248
drag-and-drop behavior, creating, 99-101, 103
DragDrop events, 99-100
DragEnter events, 99
drawing
   cards, 208
   circles, 129
   filling in outlines, 169-170
   lines, 326
   OnPaint method, 169-171, 223-225
   outlines, 167-168
   System.Drawing namespace, 274
   vector methods, 326-327
drivers, testing classes with, 13

E
Embedded Resource Build Action, 203
embedded resources, 303
Enum class, 306, 308. See also enumerations
enumerations
   creating, 74-75
   Enum class, 306, 308
   Face Value enumeration example, 204
   GetEnumerator method, 251
   GetName method, 306
   GetValues method, 308
   icons, 303
   IEnumerable interface, 245, 251-258
   IEnumerator interface, 251-258
   for interfaces, 239
   Parse method, 306
   Suit enumeration example, 203
equality, overloading meaning of, 321-322
Equals method, 322-323
error conditions. See exceptions
event handling
   AddHandler statements, 184-185
   adding handlers, 184-186, 194
   AddressOf keyword, 186
   changing handlers, 186
   creating event handlers, 182
   Handles keyword, 184-185
   Load, 233
   multiple controls, single method for, 328-330
   naming, 367
   Observer design pattern, 374
   RemoveHandler statements, 186
   run-time addresses, 186
   SelectedIndexChanged, 308-309
   signatures of handlers, 173
   train tracks example events, 165
event methods, 184-187. See also event handling
EventArgs class, 171, 194
events
   associating methods with, 184-186
   casing, 366-367
   constructors of, 172
   creating, 171-174
   declaring, 171-173, 194
   DefaultEvent attribute code, 173
   delegates, 173, 176, 180, 186-187
   deriving from EventArgs class, 171-172
   design considerations, 366-367
   drag-and-drop behavior, creating, 99-101
   EventArgs class, 194
   Handles keyword, 184-185
   handling. See event handling
   inheritance of, 273
   listening of methods, 180
   naming, 366-367
   properties, adding, 172
   raising, 174-176, 180
   signatures, 171
   UML representation of, 165
   WithEvents keyword, 184-185
exceptions
   catching, 187, 193, 195
   constructors, 190-191
   creating, 227-228
   declaring classes, 190
   defined, 33, 187
   deriving exception classes, 189-191, 194-195
   generating, 189-191
   handling Parse errors, 298-299
   Inner property, 190
   testing, 193
   throwing, 187-190, 195
   try blocks, 193

F
fields
   adding to classes, 7, 26
   adding to forms, 22-23
   adding using C# Field Wizard, 19-20
   camel Casing, 360-361
   constant, 168
   creating, 294, 296-297, 314
   defined, 7
   events as. See events, creating
   initializing, 7
   private, 31
   as properties, 43
   properties, compared to, 9
   protected, 133
   Pull Up Field refactoring, 368-372
   shared, 294, 296-297, 314
   static, creating, 296-297, 314
FillPath class, 170-171
fire on the tracks example. See train tracks example
flow control, 163
For Each, IEnumerable interface, 245, 265
formatting
   handling Parse errors, 298-299
   IFormattable interface, 245, 258-263
   strings, 110
forms
   adding controls, 22-23
   controls in. See controls
   designer, 169, 194
   as observers, 374
   synchronization problem, 373
Forms Designer
   adding handlers, 194
   viewing, 169
functions, static, 294

G
GamesLibrary control library
   adding Card control to toolbox, 210-211
   application, adding project, 210
   attribute importation, 204-205
   Card control creation, 202
   Card properties, setting, 202
   CardOver method, 228
   CheckForPair method, 230-231
   Clicks property, 225
   control size restriction, 208-209
   controls, adding to Toolbox, 232
   Count property, 218
   creation, 201
   Deck component, creating, 212-213
   default property for, 218-219
   Dispose method, 217
   drawing the Memory control, 223-225
   EventArgs class, 226
   exceptions, 227-228
   FaceUp property, 206
   FaceValue enumeration, 204
   FaceValue property, 204-205, 214-215
   forms, adding Deck component to, 220-221
   GameOver event handler, 233-234
   icon definition for Deck component, 213-214
   implementing playing, 225-228
   indexer for, 218-219
   Load event handler, 233
   MakeDeck method, 215-216
   Memory control creation, 221-227
   painting cards, 207-208
   Play method, 228-230
   Properties window for, 211-212
   Shuffle method, 217
   Suit enumeration, 203
   Suit property, 205-206, 214-215
   Suit selection, 220-221
   toolbox, adding Deck component to, 219
   Toolbox icon for Card control, 203
   user interface creation, 232-233
garbage collection, Dispose method, 217
get, defined, 9
GetEnumerator method, 251
GetHashCode method, 322-323
GetManifestResourceStream method, 304
GetName method, 304, 306
GetPage method, 10, 15
getters, 9, 44
GetType method, 308
GetValues method, 308
global data, 314
graphics. See also bitmaps; drawing; icons
   cards, drawing, 208
   FillMode property, 170-171
   FillPath class, 170-171
   GraphicsPath class, 129, 167-171

H
Handles keyword, 184-185
has-a relationships. See composition relationships
hash tables, 322-323

I
ICloneable interface, 245
ICollection serialization, 345
IComparable interface
   adding to a class declaration, 247-249
   defined, 245
   purpose of, 245-246
   SortablePoint class implementation, 297-298
   testing, 249-250
IComponent interface, 245
icons
   adding to forms, 94-95
   available with VS.NET, 94
   controls, definition for, 221
   defining for components, 213-214
   enumerating, 303
IDataErrorInfo interface, 245
identity concept, 15
IEEE Computer Society, 378
IEnumerable interface, 245, 251-258
IEnumerator interface, 245, 251-258
IFormattable interface, 245, 258-263
IList interface, 245
images. See bitmaps; drawing; graphics; icons
IMoveable interface
   defining, 239-240
   described, 238
   enumeration of directions, 239
   Move method, 240, 242-243
   Pawn class, implementing in, 240-243
   testing, 244-245
Implements keyword, 241, 242
Imports statement, 204, 305
indexers
   adding, 62-63, 66, 78, 218-219
   object access with ICollection, 345-346
   syntax to create, 69
   testing, 83
   this keyword with, 63
   uses for, 58
   using with properties, 66
   Visual Basic default properties, 63, 78
information hiding, 8
inheritance
   abstract base classes. See abstract classes
   base classes. See base classes
   case statements, substituting for, 132
   Class view, 113
   containment with, 263-264
   controls, 127-131
   defined, 106
   delegation with, 263-264
   derived classes, 106
   design considerations, 131-132
   of events, 273
   exception classes, 190
   Inherits keyword, 144
   interfaces, 237
   multiple, using interfaces, 263-264
   from .NET classes, 127-131
   NonInheritable keyword, 159
   overriding methods, 120-121
   overriding properties, 114-116
   protected fields, 114
   relationships represented by, 131
   SavingsAccount derived class, 111-119
   sealed classes, 159
   single vs. multiple, 132
   type-checking, 132
   virtual keyword for base class properties, 112
Inherits keyword, 144
initialization
   lazy, 310
   using this, 124
   variables during declaration, 14
InitializeComponent, 206-207
inner classes, 252-253
instance data, 294
   saving. See ADO.NET; serialization
instancing
   abstract classes, 138
   classes, 12-16
   delegates, 328
   identity concept, 15
   memory for, 294
Integer property, 26
interfaces
   adding to class declarations, 247-249
   classes implementing, 265
   data views, 264-265
   declaring, 239, 265
   default implementations, 364
   defined, 237
   defining, 239-240
   designing for reuse, 73
   enumerations for, 239
   IEnumerable, 245, 251-258
   IEnumerator, 245, 251-258
   IFormattable, 245, 258-263
   IMoveable. See IMoveable interface
   implementing in a class, 240-243
   inheritance, 237
   instantiation, 244
   method declarations, 240, 265
   multiple inheritance, 263-364
   naming, 363-364
   .NET framework, list of, 245
   prefixes, 363
   property declarations, 240, 265
   property implementation, 241-242
   references to, 244-245
   testing in console applications, 244-245
   UML diagram for, 238
Is keyword, 40
ISerializable interface, 333, 340-342
IsNothing keyword, 40
Items.Add method, 124

L
Label controls, 23
lazy initialization, 310
Library example. See Book Reader example
lines, drawing, 326
ListBox controls
   adding code to, 23-25
   adding to forms, 22-23
   arrays as data sources for, 36
   collection editor, 198
   filling with Load event handler, 307-308
   IList interface, 245
   responding to, 37
   SelectedItem property, 308
   SelectItem property, 339
   static classes, returning in, 311-312
   ToArray method, 336-337
Lists, IList interface, 245
Load event handler, 233
lock keyword, 314

M
m_ prefix, 8
Main method
   shared, 83, 103
   as startup object, 83, 103
   static, 83, 103
   testing with, 83-85
Me keyword, 115-116, 135
members, private, 77
memory allocation, 39
memory game example
   adding Card control to the toolbox, 210-211
   Deck component, 212-214, 219-221
   designing, 199-200
   game play coding, 233-234
   Games class library creation, 201-209
   idea of game, 198-199
   MakeDeck method, 216
   Memory control, 221-224
   playing features implementation, 225-232
   project creation, 209-210
   referring to library, 210
   Shuffle method, 217
   suite and value definitions, 214-215
   UML diagram of, 199
   user interface, 232-233
metadata, attributes of, 174
methods
   abstract, 139, 144, 161
   adding code to, 23-25
   adding to class definitions, 10, 26
   associating with events, 184-185
   C# Add Method Wizard, 20-22
   calling, 27, 328, 330
   casing, 364
   chaining method calls, 54
   design considerations, 364
   diagramming with UML, 139-141
   event, 184-187
   identifying for specifications, 3-4
   inherited abstract members, 146-149
   interfaces, adding from, 253
   interfaces, implementing, 240-243
   MouseDown events, 98-99
   naming, 364
   new keyword, 159-160, 161
   overloading, 79-81, 102-103
   overriding, 120-121, 135, 146
   parameters, 20, 84
   polymorphism, selection of, 122
   private, 65-66, 102
   public, creating, 102
   Shadows keyword, 159-160, 161
   shared, 298-299, 303-307, 315
   signatures, creation, 20
   static, 298-299, 303-307, 315
   testing with Main methods, 83-85
   verbs, using for identifying, 3-4
   virtual, 134-135, 159-160
Microsoft Access, DataSet creation for, 351-356
mouse events, 98-99, 279
multiple inheritance, 263-364
multiplication operator (*), overloading, 324
multiplication, vector, 319
multithreading, 314
Must keyword, 141
MustInherit keyword, 272
MustOverride keyword, 143-144
MyBase keyword, 116-117, 121, 133

N
\n escape character, 146
namespaces
   changing, 201
   Class View, 16-17
   declarations, 32
   Imports statement with, 204
   naming, 201
   renaming, 150
   using statement with, 204-205
naming
   camel Casing, 360-361
   capitalization, 7, 360-367, 375
   case insensitivity, 362
   casing, 7, 360-367, 375
   classes, 363
   event handlers, 367
   events, 366-367
   guidelines, 360
   interfaces, 363-364
   m_ prefix, 8
   methods, 364
   Pascal Casing, 360-361
   prefixes, 362-363
   properties, 365-366
   Visual Basic case insensitivity, 362
.NET design guidelines, 360-367
   case insensitivity, 362
   classes, 363
   delegates, 366-367
   events, 366-367
   interfaces, 363-364
   members of classes, 363-367
   methods, 364
   naming objects, 360
   prefixes, 362-363
   properties, 365-366
   Web site for, 360
new keyword
   with constructors, 29-30
   memory allocation, 39
   methods with, 159-161
new projects, creating, 5
new text lines, forcing, 146
NonInheritable keyword, 159, 161
Nothing value, 40
null value, 39-40
NumericUpDown controls, 22-23, 325-327

O
Object base class, 17, 21
object graphs, traversing, 340-342
object-oriented programming
   abstraction, 73
   containment, 73, 263-264
   identity concept, 15
   information hiding, 8
   inheritance. See inheritance
   polymorphism. See polymorphism
   references for, 377-378
   state, maintaining consistency of, 7
   UML diagrams. See UML
objects
   identifying during design, 2-3
   naming guidelines, 360
Observer pattern, 373-374
OleDbDataAdapter, 352
OnPaint method, 169-171, 223-225
OnSizeChanged method, overriding, 169
operator overloading
   + (addition operator), 323
   * (multiplication operator), 324
   != operator, 321-322
   == operator, 321-322, 330
   assignment operators, 320
   overloadable operators, list of, 320
   purpose of, 317, 320
   syntax of, 322
overloaded methods
   creating, 79-81, 102-103
   Equals method, 322-323
   GetHashCode method, 322-323
   IFormattable interface, based on, 258-263
overloading operators. See operator overloading
Overridable keyword, 114, 120, 134-135
override keyword, 34, 115, 120, 134, 146, 159, 161
Overrides keyword, 34, 114, 120, 134, 146, 159, 161
overriding methods
   base class methods, 120-121, 135
   defined, 34
   derived methods, 120-121, 135
   implementing abstract members, 161
   MustOverride keyword, 143-144
   .NET methods, 128-129
   new keyword, 159-160
   overloaded methods, 323
   Shadows keyword, 159-160
   Withdraw method, 120-121
overriding properties
   base properties, 114
   derived properties, 114-115
   implementing abstract members, 161
   MustOverride keyword, 143-144
   Overridable keyword for, 114, 134
   override keyword for, 114, 134
   Overrides keyword for, 114, 134
   virtual keyword for, 114, 134

P
Paint event handler, 225
   creating, 206-208
   Draw method with, 272, 275, 288
   OnPaint method, compared to, 225
   Refresh statement, 205
painting. See drawing; OnPaint method
Panel controls, 93
parameters
   camel Casing, 360-361
   passing by value, UML indication of, 140
Parse method, 294, 298-299, 306
Pascal Casing, 360-361, 375
passing by value, UML for, 140
PATH, 206-207
pattern maker example
   BitmapPattern class creation, 280-282
   BitmapPatternEditor class creation, 282-285
   Clone method, 276, 282
   Draw method, 275, 278, 281, 284, 288
   DrawPattern class creation, 274-276
   DrawPatternEditor class creation, 276-280
   editing patterns, 289-291
   flow control, 270-271
   GetEditor method, 272, 275-276, 281-282
   idea of, 267-268
   Pattern class, creating, 271-272
   Pattern class, description of, 268-269
   PatternButton class creation, 287
   PatternEditor class, creating, 272-273
   PatternEditor class, description of, 269-270
   project creation, 271
   refactoring of, 368-372
   template instance creation, 288-289
   testing, 291
   user interface construction, 285-291
patterns. See design patterns
Pawn class, 240-243
PictureBox controls, 176-177
playing cards example. See also GamesLibrary control library
   BetterCard project, 303-309
   Card class creation, 74-77, 302-309
   Deal method creation, 91-92
   Deck class creation, 87-92
   displaying cards on form, 96-98
   Draw method creation, 92
   Hand class creation, 77-84
   memory game. See memory game example
   pair elimination method, 81-82
   purpose of, 72
   running application, 101-102
   Shuffle method creation, 90-91
   testing Hand class, 83
   user interface, 93-102
pointer type, 38
points. See also SortablePoint class
   sorted point lists, 251-258
   System.Drawing.Point, 274
polymorphism
   advantages of, 268-269, 289
   defined, 106
   derived classes used for, 267
   design considerations, 131
   multiple inheritance, 263-264
   preventing. See new keyword; Shadows keyword
   using derived classes, 122
prefixes, 362-367
private keyword
   camel Casing, 360-361
   fields, inheritance of, 114
   methods, creating, 102
projects
   creating, 5
   importing classes into, 30-31
   running, 15-16
properties
   abstract, 139, 143, 161
   adding, 8-9, 26, 31
   C# Property Wizard, 49
   casing names of, 365-366
   categories, assigning with Properties window, 235
   changing with Property Pages dialog box, 86-87
   controls, adding to, 221-223
   creating, 48-51, 68-69
   default, adding, 62-63, 66, 70, 78
   defined, 9
   derived classes, redefining for, 112
   descriptions, assigning with Properties window, 235
   design considerations, 44, 365-366
   diagramming with UML, 139-141
   documentation comments, 69
   Embedded Resource Build Action, 203
   fields as, 43
   fields, compared to, 9
   getters, 44
   identifying for specifications, 4
   independence requirement, 44
   indexers, adding, 62-63
   of interfaces, 238, 240, 241-242
   MustOverride keyword, 143
   naming, 365-366
   overriding, 114-116, 134
   parameters, taking, 46, 69
   purpose of, 9, 43
   read-only, 44, 68
   read-write, 44, 68
   setters, 9, 27, 44, 63
   shared or static, 315
   syntax, 8-9, 26-27
   UML, 139-141, 238
   virtual, 112
   write-only, 44, 68-69
Properties window, 235
Property Wizard, C#, 49
protected fields, 114, 133
public keyword
   constructors with, 30
   interfaces, denied for, 240
   methods, creating, 102
   use of, 8
publish-subscribe design pattern, 373-374
Pull Up Field refactoring, 368-372, 375

R
RaiseEvent keyword, 175
randomizing, 90
Reader example. See Book Reader example
reading data. See deserialization
read-only properties, 44, 48-49, 68
read-write properties, 44, 68
refactoring
   defined, 368
   Pull Up Field objective, 368, 375
   reference for, 377
reference type
   defined, 38-39
   testing value of, 40-41
   value before initialization, 39
references
   adding, 210, 219
   to interfaces, 244-245
   public members of derived classes, 273
   Singleton design patterns, 312
reflection, 174
Refresh statement, 205, 279
relationships, structural, 106
RemoveHandler statements, 186
RichTextBox controls, 23
run time creation of controls, 96-98, 103

S
Saved event
   adding to controls, 276, 280, 285
   implementation, 272-273
saving data
   databases, 348-356
   options for, 331
   serialization, 331-347
scalar multiplication, 319-324
scope, prefixes indicating, 363
scrolling, 93
sealed classes, 159, 161
select statements, substituting inheritance for, 132
semicolons (;), 32
sender parameters, 290
serialization, 331-347
   application standards, 331-332
   binary, 332-337
   BinaryFormatter class, 342-343, 357
   controlling content of, 340-341
   custom, 357
   defined, 331
   deserialization, 331
   Deserialize method, 343, 357
   files, declaring, 342
   ICollection, 345
   indexers for object access, 345-346
   ISerializable interface, 333, 340-342, 357
   methodology of, 332-333
   object graphs, traversing, 340-342
   Serializable attribute, 340-342, 357
   Serialization method, 357
   SerializationInfo type, 341
   Serialize method, 342-343
   serializing the data, 342-343
   stream creation, 342-343
   StreamingContext parameter, 341
   supporting, 357
   XML serialization, 344-347
set, defined, 9
setters
   defined, 9, 44
   implementing for indexers, 63
   properties, setting with, 27
Shadows keyword, 159-161
shared data, 294
Shared Main methods, 83-85, 103
shared members
   calling, 299, 315
   classes, 309-313
   constructors, 302-307, 315
   defined, 294
   design considerations, 314
   fields, 296-297, 314
   methods, 298-299, 315
   multithreading with, 314
   properties, 315
   public data, 314
   purpose of, 302
   Singleton design pattern, 309-313
   SortedLists, 302-309
signatures of events, 171
single inheritance, 132
Singleton design pattern, 309-313
SizeChanged events, 208-209
Solution Explorer
   displaying, 5
   View Code command, 23
solutions, adding second project to, 210
SortablePoint class
   Center property for, 297
   creating, 246-247
   formatting options, custom, 258-263
   purpose of, 246
   running, 302
   shared field with, 295-297
   static field with, 295-297
   testing, 299-301
SortedCollection class, 19
SortedList class
   adding to projects, 18-20
   defined, 18-19
   disadvantages of, 151-152
   shared or static, 302-309
   using, 94-95
SortedPointList class creation, 251-258
sorting, IComparable interface, 245
SourceFile class, designing
   browsing file structures, code for, 55-57
   class creation, 48
   classes, finding in code, 54
   constructor creation, 52-54
   Display button, code for, 57-58
   field creation, 48
   object of, 45-46
   properties, creating, 48-51
   public members, 46
   testing, 58
   user interface creation, 47
specifications, text-file display example, 2-4
SQL, defining DataSets with, 352
stack overflow errors, 121
state, preserving. See serialization
static data, 294
static function variables, 294
static Main methods, 83-85, 103
static members
   calling, 299, 315
   classes, 309-313
   constructors, 302-307, 315
   defined, 294
   design considerations, 314
   fields, 296-297, 314
   methods, 298-299, 315
   multithreading with, 314
   overloaded operators, 322
   properties, 315
   public data, 314
   purpose of, 302
   Singleton design pattern, 309-313
   SortedLists, 302-309
streams
   GetManifestResourceStream method, 304
   serializing data with, 342-343
String.Format method, 110
strings
   conversion to integers, 37
   IFormattable interface, 245, 258-263
   new lines, forcing, 146
   parsing, 298
   ToString method, 192, 259-262
subclasses. See derived classes
subtraction, vector, 319
<summary> tag, 49
superclasses. See base classes
SyncLock keyword, 314
System.Collections, 19
System.Double values, 248
System.object, 125

T
templates, Windows Control Libraries, 201
testing
   Build Action properties, 203, 221, 303
   classes in class libraries, 209
   console applications, 244-245
   drivers, 13
   exception handling, 193
   IComparable interface, 249-250
   rebuilding solutions, 232
   running code (F5), 15-16
   Shared Main method, 83-85
text, serializing. See XML serialization
this keyword
   initializing properties using, 124
   overriding methods, 135
   purpose of, 115-116
throwing exceptions, 187. See also exceptions
Tick event, 175, 179-180
Timer controls, 174-175, 179-180
toolboxes
   Add Tab command, 210
   components, adding, 219, 235
   controls, adding, 235
   custom controls, adding, 210-211
   icons, defining, 203
   OleDbDataAdapter, 352
ToString method, 192, 259-262, 334-336
TrackBar controls, 181-183
tracks example. See train tracks example
train tracks example
   CaughtOnFire event, 165, 171-177
   design, 166
   DistanceChanged event, 165, 179-181, 182
   drawing track, 167-171
   events of, 165
   fire, creating, 176-177
   FireFrequency property, setting, 174-175
   idea of, 164
   ReStart method, 178-179
   testing, 184
   Track class creation, 166-170
   Train class creation, 177-181
   user interface, 181-183
triangle example. See binary serialization example
try blocks, 193
Type class, 308
typed collection classes, 152-158
typeof operator, 308
types. See data types

U
UML (Unified Modeling Language)
   aggregation relationships, 200
   class elements, 140-141
   composition relationships, 164, 200
   derived classes, 270
   events, 165
   interfaces, 238
   methods, 140
   properties, 140
   purpose of, 139-141
   references for, 377
unary operators, overloading, 323, 330
Unified Modeling Language. See UML
unsafe coding, 38
user interfaces
   Code Analysis example, 47
   creating, 22-23
   GamesLibrary control library, 232-233
   pattern maker example, 285-291
   playing cards example, 93-102
UserControl class
   BitmapPatternEditor class creation, 282-285
   Card control creation from, 202
   PatternEditor class derived from, 272-273
   Saved event, adding to, 276, 280, 285
   Size property, 167
using keyword, 19, 204-205

V
value type, 39
variables
   camel Casing, 360-361
   initializing during declaration, 14
   types of, 38-39
vector algebra application, 320-329
   + (addition operator), overloading, 323
   * (multiplication operator), overloading, 324
   != operator, overloading, 321-322
   == operator, overloading, 321-322
   drawing methods, 326-327
   interface implementation, 324-329
   logic, adding using delegates, 327-328
   Parse method, 324
   testing, 329
   ToString method, 324
   Vector class creation, 321
   vector mathematics, 318-319
vector mathematics, 318-319
virtual keyword
   base class properties, 112, 159
   methods, overriding, 134-135, 159
   overriding properties with, 114
Visual Basic, case insensitivity of, 362

W
Windows Control Libraries, 201
Windows Forms Designer, derived class designing, 272-273
WithEvents keyword, 184-185
write-only properties, 44, 68-69
writing data. See serialization

X
XML, DataSet representation by, 354
XML documentation
   returns tag, 52
   <summary> tag, 49
   comments, C#, 69
   creating documentation file, 49
XML serialization, 344-347, 357



Last Updated: January 12, 2002
Top of Page