Accelerated C# 2010

Accelerated C# 2010

Description

I am still reading the book but so far I have found the author to have done a very good job describing the C# Language. I am having a very easy time reading thing book due to his great examples and how he describes everything, though some things can get a little wordy but what programming book isn`t. I definitely recommend this book for anyone looking to learn C# or further their knowledge in C#.

Table of contents

Prelim......Page 1
Contents at a Glance......Page 7
Contents......Page 9
About the Author......Page 23
About the Technical Reviewer......Page 24
Acknowledgments......Page 25
Preface......Page 26
About This Book......Page 27
C#......Page 31
C++......Page 32
Example of a C# Program......Page 33
Overview of Features Added in C# 2.0......Page 35
Overview of Features Added in C# 3.0......Page 36
Summary......Page 37
C# and the CLR......Page 39
The JIT Compiler in the CLR......Page 40
Assemblies and the Assembly Loader......Page 41
Naming Assemblies......Page 42
Metadata......Page 43
Summary......Page 45
C# Is a Strongly Typed Language......Page 47
Expressions......Page 48
Statements and Expressions......Page 50
Types and Variables......Page 51
Value Types......Page 53
Enumerations......Page 54
Flags Enumerations......Page 55
Reference Types......Page 56
Default Variable Initialization......Page 57
Implicitly Typed Local Variables......Page 58
Type Conversion......Page 60
Boxing Conversion......Page 61
as and is Operators......Page 62
Generics......Page 64
Namespaces......Page 65
Defining Namespaces......Page 66
Using Namespaces......Page 67
switch......Page 69
foreach......Page 70
Summary......Page 71
Classes, Structs, and Objects......Page 73
Class Definitions......Page 75
Fields......Page 76
Methods......Page 79
Instance Methods......Page 80
Declaring Properties......Page 81
Read-Only and Write-Only Properties......Page 83
Auto-Implemented Properties......Page 84
Encapsulation......Page 86
Accessibility......Page 89
Interfaces......Page 91
Inheritance......Page 92
Implicit Conversion and a Taste of Polymorphism......Page 93
Member Hiding......Page 95
The base Keyword......Page 98
sealed Classes......Page 99
abstract Classes......Page 100
Nested Classes......Page 101
Indexers......Page 104
partial Classes......Page 106
partial Methods......Page 107
Static Classes......Page 109
Reserved Names for Destructors......Page 111
Constructors......Page 112
The Meaning of this......Page 114
Interfaces......Page 117
Anonymous Types......Page 118
Object Initializers......Page 121
Boxing and Unboxing......Page 124
When Boxing Occurs......Page 128
Efficiency and Confusion......Page 130
System.Object......Page 131
Equality and What It Means......Page 132
Using new with Class Types......Page 133
Field Initialization......Page 134
Static (Class) Constructors......Page 136
Instance Constructor and Creation Ordering......Page 139
Finalizers......Page 143
Deterministic Destruction......Page 144
Exception Handling......Page 145
The IDisposable Interface......Page 146
The using Keyword......Page 148
Method Parameter Types......Page 149
ref Arguments......Page 150
out Parameters......Page 152
Method Overloading......Page 153
Optional Arguments......Page 154
Named Arguments......Page 155
Inheritance and Virtual Methods......Page 158
override and new Methods......Page 159
sealed Methods......Page 161
Choosing Between Interface and Class Inheritance......Page 162
Delegation and Composition vs. Inheritance......Page 164
Summary......Page 166
Interfaces and Contracts......Page 167
Interfaces Define Types......Page 168
What Can Be in an Interface?......Page 169
Interface Inheritance and Member Hiding......Page 170
Explicit Interface Implementation......Page 173
Overriding Interface Implementations in Derived Classes......Page 175
Interface Member Matching Rules......Page 180
Explicit Interface Implementation with Value Types......Page 184
Versioning Considerations......Page 186
Contracts Implemented with Classes......Page 187
Interface Contracts......Page 189
Choosing Between Interfaces and Classes......Page 190
Summary......Page 194
Types and Formats of Overloaded Operators......Page 195
Does Parameter Order Matter?......Page 197
Overloading the Addition Operator......Page 198
Operators That Can Be Overloaded......Page 199
Comparison Operators......Page 200
Conversion Operators......Page 203
Boolean Operators......Page 206
Summary......Page 209
How the CLR Treats Exceptions......Page 211
Changes with Unhandled Exceptions Starting with .NET 2.0......Page 212
Syntax Overview of the try, catch, and finally Statements......Page 213
Rethrowing Exceptions and Translating Exceptions......Page 216
Exceptions Thrown in Finalizers......Page 219
Exceptions Thrown in Static Constructors......Page 221
Who Should Handle Exceptions?......Page 222
Achieving Exception Neutrality......Page 223
Basic Structure of Exception-Neutral Code......Page 224
Constrained Execution Regions......Page 229
Critical Finalizers and SafeHandle......Page 231
Creating Custom Exception Classes......Page 236
Working with Allocated Resources and Exceptions......Page 237
Providing Rollback Behavior......Page 241
Summary......Page 244
String Overview......Page 245
String Literals......Page 246
Format Specifiers and Globalization......Page 247
Object.ToString, IFormattable, and CultureInfo......Page 248
Creating and Registering Custom CultureInfo Types......Page 249
Format Strings......Page 251
Console.WriteLine and String.Format......Page 252
Examples of String Formatting in Custom Types......Page 253
ICustomFormatter......Page 254
Comparing Strings......Page 257
Working with Strings from Outside Sources......Page 258
StringBuilder......Page 260
Searching with Regular Expressions......Page 262
Searching and Grouping......Page 264
Replacing Text with Regex......Page 268
Regex Creation Options......Page 270
Summary......Page 272
Introduction to Arrays......Page 273
Implicitly Typed Arrays......Page 274
Type Convertibility and Covariance......Page 277
Sortability and Searchability......Page 278
Vectors vs. Arrays......Page 279
Multidimensional Rectangular Arrays......Page 281
Multidimensional Jagged Arrays......Page 283
Comparing ICollection with ICollection......Page 285
Collection Synchronization......Page 287
Lists......Page 288
Sets......Page 289
System.Collections.ObjectModel......Page 290
Efficiency......Page 292
IEnumerable, IEnumerator, IEnumerable, and IEnumerator......Page 294
Types That Produce Collections......Page 297
Iterators......Page 298
Forward, Reverse, and Bidirectional Iterators......Page 303
Collection Initializers......Page 307
Summary......Page 308
Overview of Delegates......Page 309
Delegate Creation and Use......Page 310
Single Delegate......Page 311
Delegate Chaining......Page 312
Iterating Through Delegate Chains......Page 314
Unbound (Open Instance) Delegates......Page 315
Events......Page 318
Anonymous Methods......Page 322
Captured Variables and Closures......Page 325
Beware the Captured Variable Surprise......Page 327
Anonymous Methods as Delegate Parameter Binders......Page 330
The Strategy Pattern......Page 334
Summary......Page 335
Generics......Page 337
Difference Between Generics and C++ Templates......Page 338
Efficiency and Type Safety of Generics......Page 339
Generic Classes and Structs......Page 341
Generic Interfaces......Page 344
Generic Methods......Page 345
Generic Delegates......Page 347
Generic Type Conversion......Page 350
Default Value Expression......Page 351
Nullable Types......Page 353
Generics and Inheritance......Page 355
Constraints......Page 357
Coand Contravariance......Page 362
Covariance......Page 364
Contravariance......Page 367
Invariance......Page 369
Variance and Delegates......Page 370
Generic System Collections......Page 374
Generic System Interfaces......Page 375
Conversion and Operators within Generic Types......Page 377
Creating Constructed Types Dynamically......Page 387
Summary......Page 388
Threading in C# and .NET......Page 391
Starting Threads......Page 392
Passing Data to New Threads......Page 393
Using ParameterizedThreadStart......Page 395
States of a Thread......Page 396
Terminating Threads......Page 399
Halting Threads and Waking Sleeping Threads......Page 401
Foreground and Background Threads......Page 402
Thread-Local Storage......Page 403
How Unmanaged Threads and COM Apartments Fit In......Page 407
Synchronizing Work Between Threads......Page 408
Lightweight Synchronization with the Interlocked Class......Page 409
SpinLock Class......Page 415
Monitor Class......Page 417
Beware of Boxing......Page 421
Pulse and Wait......Page 422
Locking Objects......Page 426
ReaderWriterLock......Page 427
ReaderWriterLockSlim......Page 430
Mutex......Page 431
Semaphore......Page 432
Events......Page 434
Win32 Synchronization Objects and WaitHandle......Page 435
Using ThreadPool......Page 437
Asynchronous Method Calls......Page 438
Timers......Page 446
Concurrent Programming......Page 447
Task Class......Page 448
Parallel Class......Page 450
Easy Entry to the Thread Pool......Page 455
Summary......Page 456
Reference Type Canonical Forms......Page 459
Default to sealed Classes......Page 460
Use the Non-Virtual Interface (NVI) Pattern......Page 461
Is the Object Cloneable?......Page 464
Is the Object Disposable?......Page 470
Does the Object Need a Finalizer?......Page 473
What Does Equality Mean for This Object?......Page 480
Reference Types and Identity Equality......Page 481
Overriding Object.Equals for Reference Types......Page 484
If You Override Equals, Override GetHashCode Too......Page 487
Does the Object Support Ordering?......Page 491
Is the Object Formattable?......Page 493
Is the Object Convertible?......Page 497
Prefer Type Safety at All Times......Page 499
Using Immutable Reference Types......Page 503
Value Type Canonical Forms......Page 506
Override Equals for Better Performance......Page 507
Do Values of This Type Support Any Interfaces?......Page 511
Implement Type-Safe Forms of Interface Members and Derived Methods......Page 512
Summary......Page 514
Checklist for Reference Types......Page 515
Checklist for Value Types......Page 516
Introduction to Extension Methods......Page 519
How Does the Compiler Find Extension Methods?......Page 520
Under the Covers......Page 523
Code Readability versus Code Understandability......Page 524
Consider Extension Methods Over Inheritance......Page 525
Isolate Extension Methods in Separate Namespace......Page 526
Transforms......Page 527
Operation Chaining......Page 532
Custom Iterators......Page 533
Borrowing from Functional Programming......Page 535
The Visitor Pattern......Page 541
Summary......Page 545
Introduction to Lambda Expressions......Page 547
Lambda Expressions and Closures......Page 548
Closures in C# 1.0......Page 551
Closures in C# 2.0......Page 553
Expression Trees......Page 554
Operating on Expressions......Page 557
Functions as Data......Page 558
Iterators and Generators Revisited......Page 559
More on Closures (Variable Capture) and Memoization......Page 563
Currying......Page 568
Anonymous Recursion......Page 570
Summary......Page 571
LINQ: Language Integrated Query......Page 573
Query Expressions......Page 574
Extension Methods and Lambda Expressions Revisited......Page 576
Standard Query Operators......Page 577
The from Clause and Range Variables......Page 579
The join Clause......Page 580
The where Clause and Filters......Page 582
The orderby Clause......Page 583
The select Clause and Projection......Page 584
The let Clause......Page 586
The group Clause......Page 587
The into Clause and Continuations......Page 590
C# Iterators Foster Laziness......Page 592
Subverting Laziness......Page 593
Executing Queries Immediately......Page 595
Custom Standard Query Operators and Lazy Evaluation......Page 596
Replacing foreach Statements......Page 605
Summary......Page 606
What does dynamic Mean?......Page 607
How Does dynamic Work?......Page 610
Call Sites......Page 612
Objects with Custom Dynamic Behavior......Page 615
Efficiency......Page 617
Boxing with Dynamic......Page 619
Dynamic Conversions......Page 620
Implicit Dynamic Expressions Conversion......Page 621
Dynamic Overload Resolution......Page 622
Dynamic Inheritance......Page 624
You Cannot Implement dynamic Interfaces......Page 625
You Can Derive From Dynamic Base Types......Page 627
Duck Typing in C#......Page 629
ExpandoObject: Creating Objects Dynamically......Page 632
Summary......Page 637
A......Page 639
C......Page 640
D......Page 643
E......Page 644
G......Page 645
I......Page 646
L......Page 648
M......Page 649
O......Page 650
P......Page 651
R......Page 652
S......Page 653
T......Page 655
U......Page 656
Y......Page 657

Details

  • Author: Trey Nash
  • Edition: 1
  • Publication Date: 2010
  • Publisher: Apress
  • ISBN-10: 1430225378
  • ISBN-13: 9781430225379
  • Pages: 657
  • Format: pdf
  • Size: 7.0M
Download Now Magnet