Christian Gross9781590598696, 1590598695
– Everything to get you started with C# 2008 from scratch – from installing the tools to writing your first applications.
– All the core concepts of .NET 3.5 programming: from decision trees to data structures, exceptions to lambda expressions and from objects to components.
– Learn what LINQ is, why functional programming can be important, how generics make your life easier and much, much, more!
Who is this book for?
This book is for anyone who’s just starting out to learn about C#. It doesn’t assume any prior knowledge of object-oriented programming, of the .NET Framework, or of coding in general. It simply assumes that you’re an intelligent person who wants to learn and starts the journey from there. About the Apress Beginning Series The Beginning series from Apress is the right choice to get the information you need to land that crucial entry-level job. These books will teach you a standard and important technology from the ground up because they are explicitly designed to take you from “novice to professional.” You’ll start your journey by seeing what you need to know–but without needless theory and filler. You’ll build your skill set by learning how to put together real-world projects step by step. So whether your goal is your next career challenge or a new learning opportunity, the Beginning series from Apress will take you there–it is your trusted guide through unfamiliar territory!
Table of contents :
Beginning C# 2008: From Novice to Professional……Page 1
Contents at a Glance……Page 7
Contents……Page 9
About the Author……Page 19
About the Technical Reviewer……Page 21
Introduction……Page 23
Downloading and Installing the Tools……Page 25
Downloading Visual C# Express……Page 26
Installing Visual C# Express……Page 27
Creating Projects and Solutions……Page 28
Creating the Windows Application……Page 29
Renaming the Solution……Page 30
Running the Windows Application……Page 31
Making the Windows Application Say Hello……Page 33
Adding Comments to the Application……Page 36
Navigating the User Controls of the Solution……Page 37
Making the Console Application Say Hello……Page 40
Adding a Class Library Project to the Solution……Page 41
Moving Functionality……Page 42
Calling Class Library Functionality……Page 43
Using Variables and Constants……Page 45
Understanding How the .NET Framework Works……Page 47
The Important Stuff to Remember……Page 49
Some Things for You to Do……Page 50
Focusing and Organizing Your Development……Page 51
Organizing the Calculator……Page 52
Focusing the Calculator……Page 54
Implementing the Class Library……Page 56
Writing the Add() Method……Page 58
Writing Code to Test the Add() Method……Page 61
Adding a Test Project to Your Solution……Page 62
Testing Simple Addition……Page 63
Testing the Addition of Two Very Large Numbers……Page 64
Understanding Problems with Numeric Numbers……Page 66
Understanding Value and Reference Types……Page 68
Understanding the CLR Numeric Types……Page 69
Finishing the Calculator……Page 73
Some Things for You to Do……Page 74
Organizing the Translation Application……Page 77
Building the Translator Application……Page 78
Translating Hello……Page 79
Creating the Test Application……Page 80
Investigating the String Type……Page 81
The Basis of All Types: Object……Page 82
The Problem: Character-by-Character Comparison……Page 85
Trimming the Whitespace……Page 87
Which Is the Best Solution?……Page 88
Writing the Tests Before Writing the Code……Page 89
Character Mapping……Page 91
Setting Culture and Language in Windows……Page 93
Parsing and Processing Numbers……Page 94
Working with Cultures……Page 96
The Important Stuff to Remember……Page 98
Some Things for You to Do……Page 99
Understanding the Depth-First Search Algorithm……Page 101
Value Type Constraints……Page 105
The Effects of Copying Data……Page 106
Value Types That Contain Reference Types……Page 108
Value Types and Parameters……Page 109
Organizing the Search Algorithm……Page 111
Defining and Implementing the Data Structure……Page 113
Instantiating and Initializing a Node……Page 115
Examining the Problem of Referencing Using Value Types……Page 116
Switching to a Class to Define a Node……Page 118
Understanding Static Data Members and Methods……Page 120
Defining the Algorithm Test……Page 123
The Problem of Magic Data……Page 124
Getting the Found Route……Page 125
Implementing the Depth-First Search Algorithm……Page 127
The Keyhole Problem……Page 128
Using the for Loop……Page 129
Using the if Statement……Page 130
Preventing Repetition in the Route……Page 134
Running the Depth-First Search Algorithm……Page 135
The Important Stuff to Remember……Page 136
Some Things for You to Do……Page 137
Understanding Errors, Exceptions, and Exception Handling……Page 139
Running the Debugger……Page 140
Handling Exceptions……Page 141
Catching Exceptions……Page 142
Implementing Exception Handlers……Page 144
Safeguarding Against Stack Unwinding……Page 148
Using finally to Process Unfinished Tasks……Page 150
Sandboxing Your Code……Page 151
Filtering Exceptions……Page 152
Writing Defensive Code……Page 154
Using Default State……Page 157
Processing Errors That Are Warnings……Page 158
The Important Stuff to Remember……Page 159
Some Things for You to Do……Page 160
Learning the Basics of ObjectOriented Programming……Page 161
Understanding Currency Spreads……Page 162
Writing Tests for the Currency Exchange Application……Page 163
Understanding Base Classes……Page 164
Understanding Inheritance……Page 165
Using C# Properties……Page 167
Rewriting the Test Code to Use Properties……Page 168
Understanding the Problems with Properties……Page 169
Using C# Inheritance to Subclass Another Type……Page 171
Understanding Private, Protected, and Public Scope……Page 172
Using Conditional Statements……Page 174
Using Partial Classes for Verification……Page 176
Finishing the Base Class……Page 177
Adding a Constructor to ActiveCurrencyTrader……Page 178
Adding the Conversion Methods……Page 179
Adding a Constructor to HotelCurrencyTrader……Page 180
Adding the Conversion Methods to HotelCurrencyTrader……Page 181
Learning More About Preprocessor Directives, Properties, and Abstract Methods……Page 182
More Preprocessor Directive Details……Page 183
More abstract Keyword Details……Page 184
The Important Stuff to Remember……Page 186
Some Things for You to Do……Page 187
Understanding Some Basic Tax Concepts……Page 189
Organizing the Tax Application……Page 190
Programming Using Ideas……Page 191
Representing Ideas Using C# Interfaces……Page 192
Illustrating Inheritance Using a Shape, Rectangle, and Square……Page 194
Illustrating Components Using a Shape, Rectangle, and Square……Page 197
Defining the Interfaces……Page 200
Implementing a Base Class Tax Engine……Page 201
Overriding for Specialized Functionality……Page 202
Abstracting Instantiations with Factories……Page 204
Using Default Implementations……Page 205
Implementing a Base Tax Account……Page 207
Implementing a Tax Engine and Tax Account……Page 209
Assigning State When the Interface Cannot……Page 210
Implementing Ideas with Specifics……Page 211
Using the Tax Engine……Page 213
More Inheritance Details……Page 214
More Type-Casting Details……Page 220
The Important Stuff to Remember……Page 221
Some Things for You to Do……Page 222
Understanding Kernels……Page 223
Organizing the Lighting Application……Page 224
Building the Kernel……Page 225
Defining IRoom, a Placeholder Interface……Page 226
Defining the INoRemoteControlRoom Interface……Page 227
Defining the IRemoteControlRoom Interface……Page 228
Defining the ISensorRoom Interface……Page 229
Storing a Collection Using a Linked List……Page 230
Creating a Linked List……Page 232
Inserting and Removing Linked List Items……Page 233
Testing the Linked List……Page 234
Implementing Room Groupings……Page 238
Adding a Room Grouping……Page 239
Finding a Room Grouping……Page 241
Performing Operations on a Group……Page 245
Defining the Kernel As an Interface Instead of a Class……Page 246
Defining Some Rooms……Page 248
Instantiating PublicRoom and PrivateRoom……Page 249
Object Initialization with Nested Data Types……Page 251
Some Things for You to Do……Page 253
Managing Collections……Page 255
A Simple Collection Example……Page 256
The Problem of Mixed Types……Page 258
The Problem of Value Types……Page 259
Managing a Collection After C# 2.0……Page 260
The Case of the Code That Feels Wrong……Page 261
Using Delegates……Page 264
Declaring the Delegate and Using Extension Methods……Page 266
Implementing the Delegate……Page 267
Using Anonymous Delegates……Page 269
Multicasting with Delegates……Page 270
Using Lambda Expressions……Page 271
Understanding Lambda Expressions……Page 273
Implementing the Algorithm Using Lambda Expressions……Page 274
Using a Plain-Vanilla List……Page 276
Using a Key/Value Pair List……Page 277
Using a Queue……Page 278
Some Things for You to Do……Page 279
Organizing the Lottery-Prediction System……Page 281
Reading Data from the Console……Page 282
Piping Data……Page 283
Assembling the Pieces Using an Echo Program……Page 284
Reading and Writing to a Stream……Page 285
Implementing Stream Reading and Writing……Page 289
Implementing the TextProcessor Application……Page 294
Deciphering the Format……Page 297
Fixing the Stream……Page 299
Piping Binary Data……Page 302
Defining the Interfaces and Implementing the Shell……Page 304
Defining the Type……Page 307
Converting a Text Stream into a Binary Stream……Page 308
Converting a Binary Stream into a Text Stream……Page 309
Performing Custom Serialization……Page 311
Separating Data Objects from Action Objects……Page 312
Implementing GetHashCode()……Page 313
Implementing Equals()……Page 316
Some Things for You to Do……Page 318
Why Use .NET Generics?……Page 319
The Theory of a Server-Side Spreadsheet……Page 322
Designing the Architecture……Page 325
Defining the Debug Interface……Page 326
Defining the IWorksheetBase and IWorksheet Interfaces……Page 327
Defining the IWorkbook Interface……Page 331
Implementing the Server Spreadsheet……Page 335
Using Lambda Expressions in the Spreadsheet……Page 340
Assigning State Without Knowing the Type……Page 344
Overriding the ToString() Functionality……Page 346
Iterating Data Using Enumerators……Page 347
Calculating an Average……Page 348
Understanding Why the Calculation Worked……Page 350
The Important Stuff to Remember……Page 351
Some Things for You to Do……Page 352
Convention over Configuration……Page 353
Decoupling Using a Convention Architecture……Page 355
Setting Up the Dynamic Loading Projects……Page 356
Signing an Assembly……Page 358
Setting the Output Path……Page 359
Creating an XML-Based Configuration File……Page 360
Reading a Configuration File……Page 362
Dynamically Instantiating a Type……Page 363
Using Singletons……Page 365
Using the Instantiated Type……Page 366
Enhancing the Configuration File……Page 367
Marshaling the Configuration File Data……Page 368
Reading the Enhanced Configuration File……Page 370
Loading a Strongly Named Assembly……Page 372
Relocating a Strongly Named Assembly to the GAC……Page 373
Understanding Version Numbers……Page 375
Versioning Assemblies……Page 376
Adding an Assembly Redirection to a Configuration File……Page 377
Implementing a Convention-Based Architecture……Page 378
Dynamically Loading Base Class or Interface Types……Page 380
The Important Stuff to Remember……Page 381
Some Things for You to Do……Page 382
Understanding Multitasking……Page 383
Time Slicing……Page 384
Creating a New Thread……Page 387
Waiting for the Thread to End……Page 388
Implementing a ThreadStart Delegate……Page 389
Using a Thread Parameter……Page 390
Synchronizing Between Threads……Page 391
Using Exclusive Locks……Page 393
Synchronizing with Cloning……Page 395
How Not to Deadlock Your Code (Mostly)……Page 396
Implementing a Reader/Writer Threaded Architecture……Page 400
Using a Hidden Producer/Consumer Implementation……Page 404
Implementing a Generic Producer/Consumer Architecture……Page 406
Using an Asynchronous Approach……Page 408
The Important Stuff to Remember……Page 410
Some Things for You to Do……Page 411
Relational Database Tables……Page 413
Database Relations……Page 415
Accessing Relational Databases……Page 418
Designing a Database Using Visual C# Express……Page 419
Configuring the Data Source……Page 420
Adding the Tables……Page 423
Persons Table……Page 425
Winners Table……Page 426
Adding Table Data……Page 427
Deleting Data from the Database……Page 430
Recapping ADO.NET Usage……Page 431
Building Relations Between Tables……Page 432
Using the Generated Code……Page 436
Some Things for You to Do……Page 438
Finding the Frequency of Winning Numbers……Page 439
Extending the Lottery-Prediction System……Page 440
Implementing a Frequency Solution……Page 443
Borrowing Code to Solve Another Problem……Page 445
Using LINQ……Page 446
Learning More LINQ Tricks……Page 449
Selecting and Altering Data……Page 452
Selecting with Anonymous Types……Page 454
Sorting the Results……Page 455
Splitting Results into Groups……Page 457
Performing Set Operations……Page 458
Using LINQ in Other Contexts……Page 460
Some Things for You to Do……Page 462
Why Functional Programming?……Page 463
The Essence of Functional Programming……Page 465
An Academic Example……Page 466
A Practical Example: Calculating Sales Tax……Page 468
Pure Functions……Page 469
Using Immutable Types……Page 470
Manipulating Immutable Types……Page 472
Function Evaluation……Page 474
Recursion……Page 476
Some Things for You to Do……Page 477
Addition……Page 479
Bitwise Operators……Page 480
Increment and Decrement……Page 482
Overloading the Operators……Page 484
The goto Statement……Page 486
Using the type Constraint……Page 487
Using the class Constraint……Page 489
Nullable Types……Page 490
Partial Classes and Methods……Page 492
Some Things for You to Do……Page 494
Index……Page 495
Reviews
There are no reviews yet.