Daniel Solis1590599543, 9781590599549
Table of contents :
Illustrated C# 2008……Page 1
Contents at a Glance……Page 6
Contents……Page 9
About the Author……Page 25
About the Technical Reviewer……Page 27
Acknowledgments……Page 29
Introduction……Page 31
C# and the .NET Framework……Page 33
Unknown……Page 0
Goals for the Next-Generation Platform……Page 34
Components of the .NET Framework……Page 35
Automatic Garbage Collection……Page 36
No COM Required……Page 37
The Base Class Library……Page 38
Overview of Compilation and Execution……Page 41
Common Language Specification (CLS)……Page 44
Overview of C# Programming……Page 47
Types, Storage, and Variables……Page 63
Types of Members……Page 66
More About the Predefined Types……Page 68
Facts About Stacks……Page 70
The Heap……Page 71
Storing Members of a Reference Type Object……Page 72
Categorizing the C# Types……Page 73
Variable Declarations……Page 74
Automatic Initialization……Page 75
Using the Value of a Variable……Page 76
Classes: The Basics……Page 77
A Class Is an Active Data Structure……Page 78
Fields……Page 81
Declarations with Multiple Fields……Page 82
Methods……Page 83
Combining the Steps……Page 86
Private and Public Access……Page 88
Depicting Public and Private Access……Page 89
Example of Member Access……Page 90
Methods……Page 97
Code Execution in the Method Body……Page 99
Type Inference and the var Keyword……Page 101
Local Variables Inside Nested Blocks……Page 102
Flow of Control……Page 104
The Return Statement and Void Methods……Page 108
Formal Parameters……Page 110
Actual Parameters……Page 111
An Example of Methods with Input Parameters……Page 112
Expanded Form……Page 123
Arrays As Actual Parameters……Page 126
More About Classes……Page 133
Order of Member Modifiers……Page 134
Example of a Static Field……Page 138
Lifetimes of Static Members……Page 139
Constants Are Like Statics……Page 143
Property Declarations and Accessors……Page 146
A Property Example……Page 147
Using a Property……Page 148
Properties and Associated Fields……Page 149
Performing Other Calculations……Page 151
Read-Only and Write-Only Properties……Page 152
An Example of a Computed, Read-Only Property……Page 153
Example of Properties and Databases……Page 154
Automatically Implemented Properties……Page 155
Static Properties……Page 157
Constructors with Parameters……Page 159
Default Constructors……Page 160
Accessibility of Constructors……Page 162
Calling the Destructor……Page 166
The Standard Dispose Pattern……Page 168
Indexers and Properties……Page 174
Declaring an Indexer……Page 175
The set Accessor……Page 176
The get Accessor……Page 177
Declaring the Indexer for the Employee Example……Page 178
Another Indexer Example……Page 180
Indexer Overloading……Page 181
Partial Methods……Page 185
Classes and Inheritance……Page 187
All Classes Are Derived from Class object……Page 190
Virtual and Override Methods……Page 196
Case 1: Declaring Print with override……Page 198
Case 2: Declaring Print with new……Page 200
Constructor Initializers……Page 203
Class Access Modifiers……Page 205
Regions Accessing a Member……Page 209
Private Member Accessibility……Page 210
Internal Member Accessibility……Page 211
Protected Internal Member Accessibility……Page 212
Summary of Member Access Modifiers……Page 213
Example of an Abstract Class and an Abstract Method……Page 216
Expressions and Operators……Page 225
Real Literals……Page 229
Precedence……Page 233
Associativity……Page 234
Comparison and Equality Operations……Page 238
Compound Assignment……Page 248
Explicit Conversion and the Cast Operator……Page 254
Restrictions on Operator Overloading……Page 256
Example of Operator Overloading……Page 257
Statements……Page 261
A Switch Example……Page 269
More on the switch Statement……Page 270
Switch Labels……Page 271
The Scope of Variables in a for Statement……Page 277
Multiple Expressions in the Initializer and Iteration Expression……Page 278
Labels……Page 281
The Scope of Labeled Statements……Page 282
The goto Statement Inside a switch Statement……Page 283
Packaging Use of the Resource……Page 285
Example of the using Statement……Page 286
Multiple Resources and Nesting……Page 287
Another Form of the using Statement……Page 288
Namespaces and Assemblies……Page 291
The mscorlib Library……Page 295
Namespace Names……Page 299
More About Namespaces……Page 300
Namespaces Spread Across Files……Page 301
Nesting Namespaces……Page 302
The using Namespace Directive……Page 303
The using Alias Directive……Page 304
Creating a Strongly Named Assembly……Page 310
Installing Assemblies into the GAC……Page 312
Side-by-Side Execution in the GAC……Page 313
Exceptions……Page 317
Handling the Exception……Page 320
General Algorithm……Page 328
Example of Searching Down the Call Stack……Page 329
Structs……Page 335
Instance Constructors……Page 339
Summary of Constructors and Destructors……Page 341
Enumerations……Page 345
Setting the Underlying Type and Explicit Values……Page 348
Implicit Member Numbering……Page 349
The Flags Attribute……Page 352
Example Using Bit Flags……Page 354
Arrays……Page 359
Important Details……Page 360
Declaring a One-Dimensional Array or a Rectangular Array……Page 363
Explicit Initialization of One-Dimensional Arrays……Page 366
Syntax Points for Initializing Rectangular Arrays……Page 367
Shortcut Syntax……Page 368
Implicitly Typed Arrays……Page 369
Putting It All Together……Page 370
Shortcut Instantiation……Page 372
Instantiating a Jagged Array……Page 373
Sub-Arrays in Jagged Arrays……Page 374
The Iteration Variable Is Read-Only……Page 378
Example with a Rectangular Array……Page 379
Example with a Jagged Array……Page 380
The Clone Method……Page 384
Delegates……Page 387
Methods in the Invocation List……Page 388
Using Anonymous Methods……Page 402
Return Type……Page 403
params Parameters……Page 404
Outer Variables……Page 405
Extension of Captured Variable’s Lifetime……Page 406
Events……Page 411
An Event Has a Private Delegate……Page 413
The Delegate Type and EventHandler……Page 416
Removing Event Handlers……Page 420
Using the EventArgs Class……Page 421
Passing Data by Extending EventArgs……Page 422
Using the Custom Delegate……Page 423
Interfaces……Page 429
Example Using the IComparable Interface……Page 431
Example with a Simple Interface……Page 437
Accessing Explicit Interface Member Implementations……Page 450
Example of Different Classes Implementing an Interface……Page 452
Conversions……Page 455
Casting……Page 459
Implicit Numeric Conversions……Page 461
The checked and unchecked Operators……Page 462
The checked and unchecked Statements……Page 463
Integral to Integral……Page 464
decimal to Integral……Page 465
float or double to decimal……Page 466
decimal to float or double……Page 467
Implicit Reference Conversions……Page 469
Explicit Reference Conversions……Page 471
Valid Explicit Reference Conversions……Page 472
Boxing Creates a Copy……Page 475
The Boxing Conversions……Page 476
The Unboxing Conversions……Page 477
Constraints on User-Defined Conversions……Page 478
Example of a User-Defined Conversion……Page 479
Example of a Multi-Step User-Defined Conversion……Page 481
Generics……Page 485
A Stack Example……Page 486
Continuing with the Stack Example……Page 489
The Stack Example Using Generics……Page 495
Comparing the Generic and Non-Generic Stack……Page 497
Where Clauses……Page 499
Constraint Types and Order……Page 500
An Example Using Generic Interfaces……Page 503
Generic Interface Implementations Must Be Unique……Page 504
Another Generic Delegate Example……Page 507
Declaring a Generic Method……Page 509
Invoking a Generic Method……Page 510
Inferring Types……Page 511
Example of a Generic Method……Page 512
Enumerators and Iterators……Page 515
Using the foreach Statement……Page 516
Types of Enumerators……Page 517
Declaring an IEnumerator Enumerator……Page 521
Example Using IEnumerable and IEnumerator……Page 524
Iterator Blocks……Page 535
Using an Iterator to Create an Enumerator……Page 536
Using an Iterator to Create an Enumerable……Page 537
Introduction to LINQ……Page 547
Anonymous Types……Page 550
The from Clause……Page 557
The join Clause……Page 559
What Is a Join?……Page 560
The from . . . let . . . where Section in the Query Body……Page 563
The from Clause……Page 564
The let Clause……Page 565
The where Clause……Page 566
The orderby Clause……Page 567
The select . . . group Clause……Page 568
Anonymous Types in Queries……Page 570
The group Clause……Page 571
Query Continuation……Page 573
Query Expressions and the Standard Query Operators……Page 576
Signatures of the Standard Query Operators……Page 577
Delegates As Parameters……Page 579
The LINQ Predefined Delegate Types……Page 581
Example Using a Delegate Parameter……Page 582
Example Using a Lambda Expression Parameter……Page 583
Markup Languages……Page 585
XML Basics……Page 586
The XML Classes……Page 588
Creating, Saving, Loading, and Displaying an XML Document……Page 589
Creating an XML Tree……Page 590
Using Values from the XML Tree……Page 591
Adding Nodes and Manipulating XML……Page 594
Working with XML Attributes……Page 596
XProcessingInstruction……Page 600
Using LINQ Queries with LINQ to XML……Page 602
Introduction to Asynchronous Programming……Page 605
Multithreading Considerations……Page 607
The Complexity of Multithreading……Page 608
The Wait-Until-Done Pattern……Page 612
The AsyncResult Class……Page 614
The Polling Pattern……Page 615
The Callback Method……Page 617
Calling EndInvoke Inside the Callback Method……Page 618
Preprocessor Directives……Page 625
Reflection and Attributes……Page 637
The Obsolete Attribute……Page 645
The Conditional Attribute……Page 646
Example of the Conditional Attribute……Page 647
Predefined Attributes……Page 648
Multiple Attributes……Page 649
Other Types of Targets……Page 650
Global Attributes……Page 651
Declaring a Custom Attribute……Page 652
Specifying the Constructor……Page 653
Using the Constructor……Page 654
Positional and Named Parameters in Constructors……Page 655
Restricting the Usage of an Attribute……Page 657
The Constructor for AttributeUsage……Page 658
Suggested Practices for Custom Attributes……Page 659
Using the IsDefined Method……Page 660
Using the GetCustomAttributes Method……Page 661
Other Topics……Page 663
Using Class StringBuilder……Page 665
Formatting Numeric Strings……Page 666
The Alignment Specifier……Page 667
The Format Component……Page 668
Standard Numeric Format Specifiers……Page 669
Creating a Nullable Type……Page 672
Assigning to a Nullable Type……Page 675
Using Operators and the Null Coalescing Operator……Page 676
Using Nullable User-Defined Types……Page 677
Nullable……Page 678
Accessibility of Main……Page 680
Inserting Documentation Comments……Page 682
Using Other XML Tags……Page 683
Example of a Nested Class……Page 685
Visibility and Nested Types……Page 686
Index……Page 689
Reviews
There are no reviews yet.