Index

NOTE: Page references marked with an n are footnotes

! logical negation operator, 118119

!=, <, <=, ==, >= relational operators, 386

&&, ||, ^ logical Boolean operators, 116118, 122126

with flag enums, 365

() (cast/conversion) operators, 6164,

custom conversion operators, 391393

%=, *=, /=, +=, -= (compound assignment) operators, 97

overloading compound assignment operators, 387389

%, *, +, -, / (arithmetic) operators, 87

+ (string) operator, 9091

%, *, +, -, / operator overloading 387389

++/-- (increment/decrement) operators, 97102

+, - (unary plus/minus) operators, 8687

+, +=, -, -= delegate operators, 540542

= assignment operators, 15

?: (conditional) operators, 119120

?? (null coalescing) operators, 120121

@ characters, 8, 47

[ ] (square brackets), 6775

attributes, 687692

indexers, 655657

(escape sequence), 44

(newline) characters, 46, 50

^ (exclusive OR) operators, 118, 122

{} (curly braces), 2, 10, 110114

|| (OR) operators, 116, 117, 122

constraints, 473474

with flag enums, 365

~ (bitwise complement) operators, 127, 64

Abort() method, 740

aborting threads, 741743

abstract classes

inheritance, 302308

compared to interfaces, 337

abstract members, 302, 303304, 305

access modifiers, 227229, 397398

internal, 396398

private, 227229, 284285, 397398

public, 227229, 398

protected, 285286, 397398

protected internal, 398

on property getters/setters, 239240

on classes, 397

array accessors, 74

Active Template Library. See ATL

Add() method, 249, 352, 473, 568569, 641

add/remove event handlers, customizing, 558

aliases qualifiers

addition (+) operators, 87, 387, 541

guidelines, 91

strings, 9091

overloading, 387389

delegate operators, 540542

addresses, 862872

advanced parameters, methods, 175184

AggregateException, 547, 757764, 768, 779, 798800

aggregation for multiple inheritance, 287290

algorithms

hill climbing, 798

mark-and-compact, 407

mark-and-sweep-based, 882

work stealing, 798

aliasing with using, 171, 401402

allocating

data on call stacks, 868

virtual memory, 851

AllocExecutionBlock() method, 855

AllowMultipleAttribute parameter, 700

alternative statements, 107

AND (&&) operator, 117118, 122126

with flag enums, 365

anonymous methods, 495, 512514

internals, 517518

anonymous types, 5657, 562564, 566568

array initialization, 570571

constructors, 253255

projecting to, 583

antecedent tasks, 753

APIs (application programming interfaces), 27

APM (Asynchronous Programming Model), 908921

AppDomain, 762

application programming interfaces. See APIs

Appointment class, 278

ArgumentException, 424

ArgumentNullException, 424

ArgumentOutOfRangeException, 424

arguments

command-line, passing, 173

methods, 161162

named, 191

arithmetic (binary) operators, 8796,

overloading, 387389

arity, 460461

ArrayList method, 350, 352

arrays, 6782

access, 68

applying, 7479

assigning, 68, 7074

command-line options, 80

covariance, support, 488489

declaring, 68, 6970

errors, 72, 8182

foreach loops, 571572

instantiation, 7074

jagged, 73, 75

length, 7576

literal values, 71

methods, 7779

parameters, 181184

redimensioning, 78

runtime, defining size at, 72

strings, 7981, 8081

three-dimensional, 73

two-dimensional, 69, 72, 7475

as operator, conversions, 310311

AsParallel() method, 584

assemblies, 4. See also libraries

CLI, 887890

metadata, viewing, 678. See also reflection

targets, modifying, 394395

versioning, 889

well-formed types, referencing, 393398

Assert() method, 95

assigning

arrays, 68

indexers, 657658

null to strings, 54

pointers, 866869

text, 42

variables, 13, 1516

assignment operators

applying, 548

binary operators, combining with, 389

compound, 96103

events, 541

associating

classes, 259

data types, 57

relationships, 217

XML comments, 403405

associativity, 88

async keyword, 777781, 937942

asynchronous delegate invocation, 921924

asynchronous programming, 732

high-latency operations, 772777

lambda expressions, 782783

methods, customizing, 783786

models, 908921

System.Threading.Thread class, 737739

Task-based Asynchronous Pattern (TAP), 770794

task-based asynchrony, 848849

asynchronous tasks, 745764

ATL (Active Template Library), 287

atomic operation, 734, 745, 829

attributes, 677, 688714

backward compatibility, 712

constructors, initializing, 694699

customizing, 692693, 893

FlagsAttribute class, 367, 701702

IndexerNameAttribute, 657

interfaces, comparing, 337338

named parameters, 700714

naming, 692

predefined, 703

searching, 693694

serialization, 706714

System.AttributeUsageAttribute class, 699700

System.ConditionalAttribute class, 703705

System.ObsoleteAttribute class, 705706

System.SerializableAttribute class, 438, 713714

automatically shimmed interfaces, 848

automatically implemented properties, 232234

Average() method, 609

await keyword, 741, 777781, 937942

background worker patterns, 928932

backing field declarations, 232, 244

backslash () escape sequence, 44

Base Class Library. See BCL

base classes

base member, 300301

finalizers in, 412

inheritance, overriding, 290302

new modifier, 295299

refactoring, 279

sealed modifiers, 299301

virtual modifiers, 290295

base members, 300301

base types, 212

BCL (Base Class Library), 25, 34, 743, 885, 892, 894

BeginGetResponse() method, 908

BeginX() method, 908

behaviors

boxing, 349357

dynamic objects, 716718

implementation-defined, 101

polymorphism, data types, 310

best practices, thread synchronization design, 827829

binary floating-point types, 37, 9296

binary (arithmetic) operators, 8796, 387389

BinarySearch() method, 643, 644

BinaryTree<T> class, 462463, 658

binding

dynamic objects, 719720

late, 893

methods, 714

runtime, XML elements, 719720

bits, 121122

bitwise

complement () operators, 127, 644

compound assignment operators, 126

operators, 121127, 140

blocks

catch, 199200, 203, 204, 428432

code blocks ({}), 110114

finally, 199200

try, 197

unsafe, 863, 864

Boolean

expressions, 107, 114121

number conversions, 64

types, 43

boxing

avoiding, 356357

value types, 349357

Break() method, 803

break statements, 139141

breaking parallel loops, 803804

brittle base classes, 295

BubbleSort() method, 496497

buffers, overrun, 76, 883

bugs, runtime performance, 885886

building custom collections, 635. See also collections, customizing

bytes, 121122

C language, 1

pointers, declaring, 865

C++ language, 1, 890

arrays, declaring, 69

buffer overrun, 76

delete operator, 216

deterministic destruction, 418, 882

evaluation order of operands, 90

global methods, 164

global variables/functions, 256

header files, 168

implementation-defined behavior, 101

implicit overriding, 292

implicitly typed variables, 565

local variable scope, 114

Main method, 10

methods, calling, 295

multiple inheritance, 287

operator errors, 115

operator-only statements, 87

pointers, declaring, 865

preprocessors, 145

pure virtual functions, 305

short data types, 35

string concatenation at compile time, 48

struct, defining with public members, 348

switch statements, 138

templates, 466

void, 55

C# without generics, 444449

caches, avoiding repeated, 590

calculating

compound assignment operators, 96103

financial, 36

operators, 86. See also operators

pi, 794795

values, bytes, 122

callers, 157

variables, matching with parameter names, 176

calling

APM methods, 915921

constructors, 245

methods, 11, 156163, 295

avoiding boxing, 356357

statements, 163

P/Invoke

APIs, 86186

external functions, 858861

SelectMany() method, 604606

sites, 175

stacks, 175, 868

Task.ContinueWith method, 752, 789

camelCase, 7, 15

Cancel() method, 766

CancellationToken class, 764, 767

CancellationTokenSource class, 767

cancelling

parallel loops, 800

PLINQ queries, 807

tasks, 764770

Capacity() method, 639

capitalizing variables, 15

capturing

loop variables, 521522

variables, 518

Cartesian products, 598, 631

CAS (code access security), 884

permissions, 686

case-sensitivity, 2

multiple strings, 43

cast (()) operators, 61, 391392

casting

inheritance, chaining, 282283

multicast delegates, 533

operators, defining, 283

types, 6566, 281282

catch blocks, 199200, 203, 204, 428432

catch clause, 779

catching exceptions, 196197, 426427

categories of types, 5760, 340

centralizing initialization, 252253

chaining

constructors, 251253

inheritance

casting, 282283

exceptions, 437

multicast delegates, 544

change() method, 942

char data types, 92

characteristics of parameter arrays, 183

characters

@, 47

escape, 45

newline ( ), 46, 50

operators, applying, 9192

Unicode, 4346, 98

checking

conversions, 6264, 440

for null, 538539

types, 883

child collections, formatting, 602

Church, Alonzo, 513

CIL (Common Intermediate Language), 24, 876, 877, 894

boxing, 350

CLI, 890. See also CLI

dynamic objects, 718719

empty catch blocks, 432

events, 556557

extension methods, 266

generics, 490491

best practices, 452453

HelloWorld output, 2930

ILDASM, 2829

indexers, 657

iterators, defining, 661

machine code, compilation to, 879880

objects

deriving, 309

initializers, 248

outer variables, implementing, 520521

properties, 243244

runtime, 881886

Stack<T> class, 490

System.SerializableAttribute class, 713714

circumventing encapsulation, 883

class keyword constraints, 468469

classes, 209210

abstract, 302308, 337

access modifiers, 227229, 397

associating, 259

base. See also base classes

base member, 300301

new modifier, 295299

overriding, 290302

refactoring, 279

sealed modifiers, 299301

constructors, 244255

anonymous types, 253255

chaining, 251253

common initializers, 249

declaring, 245246

defaults, 247

finalizers, 249250

object initializers, 247248

overloading, 250251

declaring, 8, 213216

definitions, 214

encapsulation, 215, 267269

extension methods, 265266

finalizers, 416

generics, 450452

hierarchies, 212, 324

inheritance, 277. See also inheritance

initializers, 247248

instances

fields, 217219

methods, 219220

instantiation, 213216

interfaces

comparing, 336337

conversions, 326

Java inner classes, 272

locations, 408

members, 216

memory, garbage collection, 408

methods, 157. See also methods

naming, 4, 8

nested, 269272

object-oriented programming, 210213

partial, 272273, 272276

properties, 229244

access modifiers on getters/setters, 239240

guidelines, 234235

parameter values, 242244

read-only/write-only, 237239

validation, 236237

virtual fields, 240242

sealed, inheritance, 290

static members, 255265

this keyword, 220227

types, constraints, 467468

cleanup

collection interfaces after iteration, 575

resources

APM, 914

using statements, 575

well-formed types, 410419

CLI (Common Language Infrastructure), 1, 2426, 894, xxvii

application domains, 887

assemblies, 887890

BCL, 892

CIL, 890

CLS, 891892

CTS, 891

manifests, 887890

metadata, 892893

modules, 887890

closed over variables, 518

CLR (Common Language Runtime), 881, 894

CLS (Common Language Specification), 25, 877, 891892, 895

CLU language, 660

COBOL, 890

code, xxiii

access security, 25, 884

blocks, 110114

machine, 24, 876, 879880

managed, 24, 881

native, 24

preprocessor directives, excluding/including, 146147

reuse, 394

runtime performance, 885886

unsafe, 845846, 863864, 867, 872873

whitespace, formatting, 13

collections

child, formatting, 602

classes, 638655

concurrency, 835837

customizing, 635

dictionaries, 636, 646650, 696

empty, 659660

filtering, 614

generics, 637

indexers, 655659

initializers, 568571

interfaces, 249, 561562, 636638

iterators, 660674

compiling, 671672

creating multiple in single classes, 673674

defining, 661

examples of, 666667

recursive, 669

state, 664666

syntax, 661662

yield break statements, 670671

yield return statements, 674

yielding values, 662664

linked lists, 654655

lists, 639641, 643644

multiple items, searching, 645

projecting, 614

queues, 654

sorting, 641, 652

stacks, 652654

total ordering, 643

yield return statements, placing in loops, 667669

collisions, type names, 158

COM (Component Object Model)

DLL registration, 890

STAThreadAttribute class, 842843

combining assignment operators with binary operators, 389

command-line

arguments, passing, 173

array options, 80

CommandLine class, 270

CommandLineAliasAttribute class, 694

CommandLineInfo class, 681, 684, 688, 689

CommandLineSwitchRequired-Attribute class, 692, 694

commands

preprocessor directives, 145

xcopy, 889

commas (,), 165

comments

code, 2123

well-formed types, 402407

XML, 678

Common Intermediate Language. See CIL

Common Language Infrastructure. See CLI

Common Language Runtime. See CLR

Common Language Specification. See CLS

Common Type System. See CTS

Compare() method, 495

CompareTo() method, 323, 641

generics, 463

comparison operators, 386387

ComparisonHandler delegate, 499

comparisons

equality, requirements of, 651

interfaces

attributes, 337338

classes, 336337

compilers, 878

installing, 897899

paths, configuring, 898

compiling

applications, 34

checked/unchecked conversions, 63

just-in-time compilation, 24, 466, 879

keywords, 4. See also keywords

machine code, 879880

static compilation versus dynamic programming, 720721

components, 1

composite formatting, 20

compound assignment operators, 96103

Concat() method, 608

concatenation, strings

addition (+) operators, 9091

at compile time, 48

concrete classes, 302, 305

concurrency, 732, 835837

conditional logical operators, 389

conditional (?:) operators, 119120

consequence statements, 107

consistency, integers, 35

console executable assemblies, 394

ConsoleListControl class, 316317, 320

consoles

input, 1719

output, 1921

synchronization, 920921

Console.WriteLine() method, 340, 352, 871

const values, 267

constants

expressions, 102103

fields, declaring, 267

math, 112

public, 268

constraints, 462476

class keyword, 468469

class types, 467468

constructors, 470

defaults, 474476

inheritance, 471472

interfaces, 465467

limitations, 472473

multiple, 469

specifying, 479480

struct keyword, 468469

constructors

attributes, initializing, 694699

base, specifying base, 301302

classes, 244255

anonymous types, 253255

chaining, 251253

common initializers, 249

declaring, 245246

defaults, 247

finalizers, 249250

object initializers, 247248

overloading, 250251

constraints, 470, 474476

exceptions, 418, 437

generics, defining, 457

static, 261262

Contains() method, 643

context

switches, 732

synchronization, 788790

contextual keywords, 6, 672673

continuation

passing style. See CPS

query expressions, 629630

tasks, 789

continue statement, 141143

ContinueWith() method, 753, 775, 919920

contravariance

enabling, 485488

generics, 481489

control flow

asynchronous tasks, 751

await keyword, 792794

statements, 85, 103110, 127139

do/while loops, 127129

exception-handling, 198

foreach loops, 133136

if statements, 107110

for loops, 120133

switch statements, 135139

while loops, 127129

tasks, 780

conversions

as operator, 310311

Boolean types, numbers, 64

boxing, 349357

checked, 6264, 440

CIL, 879

classes, interfaces, 326

covariant, 482. See also covariance

customizing, 283283

data types, 6067

enums, strings, 362364

exception handling without, 207

explicit, 392

implicit, 64, 392

objects, deriving, 282

operators, 391, 393

strings, 65

types

checking, 883

without casting, 6566

unchecked, 6264, 440

cooperative cancellation, 764

coordinates, 388389, 395

CopyTo() method, 638

cores, 730n2

Count() method, 585586, 609, 622

Count property, 638

CountdownEvent class, 835

counting items, 585586

CountLines() method, 157

covariance

enabling, 483485

generics, 481489

support, 488489

CPS (continuation passing style), 911913, 915

CPUs (central processing units), 730

LINQ queries, running in parallel, 584

CTS (Common Type System), 25, 877, 891, 895

curly braces ({}), 2, 10

code blocks, 110114

customizing

add/remove handlers, 558

attributes, 692693, 893

collections, 635. See also collections

classes, 638655

dictionaries, 646650

empty, 659660

indexers, 655659

interfaces, 636638

iterators, 660674

linked lists, 654655

List<T> class, 639641

queues, 654

searching items, 645

searching List<T> class, 643644

sorting, 641, 652

stacks, 652654

total ordering, 643

conversions, 283283

dictionaries, equality, 649650

dynamic objects, 721724

events, implementing, 558559

exceptions, defining, 435438

LINQ, providers, 609

methods, asynchronous, 783786

serialization, 708710

synchronization contexts, 790

cycles, processors, 728, 741

data

managed, 881

persistence to files, 224

retrieval from files, 225

types, 14, 3334

DataStorage class, 403

de-allocating objects, 882. See also allocating

deadlocks, 736, 745, 827828

decimal types, 3637

declaration spaces, 112114

decrement (--) operators, 97102

default

keyword, 68

operator, 348, 458

default constructors, 247

default constructor constraints, 474476

deferred execution

implementing, 623

query expressions, 619

standard query operators, 586590

#define preprocessor directive, 147148

delegate keyword, 542

delegates, 495

asynchronous delegate invocation, 921924

data types, 498500

events, 554555

operators, 540542

sequential invocation, 542

expression trees, 527528

generics, declaring types, 552

instances, returning, 539

instantiation, 500502

internals, 503506

invoking

events, 537538

pass-by references, 547548

returning methods, 547548

thread-safe, 539540

multicast, 533

internals, 542544

observer patterns, 534548

overview of, 496506

P/Invoke, 862

passing, 510

sequence diagrams, 545

synchronous, 747

syntax, 502

System.Func/System.Action, 514530

types, declaring, 500

unsafe code, executing via, 872873

delete (C++) operator, 216

delimited comments, 22

denominators, 35

deployment, xcopy, 889

Dequeue() method, 654

dereferencing pointers, 869871

deriving

inheritance, 278290

casting between types, 281282

customizing conversions, 283283

private access modifiers, 284285

protected access modifiers, 285286

System.Object class, 308309

types, 212

deserialization, 711. See also serialization

deterministic destruction (C++), 418, 882

deterministic finalization, 412415

device drivers, 886

dictionaries

collections, 636, 646650, 696

equality, customizing, 649650

Dictionary<T> class, 646650

directives. See also commands

preprocessor, 145152

code editors, 151152

errors/warnings, 148150

#pragma preprocessor directive, 149

specifying line numbers, 150

symbols, 147148

using, 168172

DirectoryCountLines() method, 185, 187, 191

Directory.GetFiles() method, 617

DirectoryInfoExtension.Copy() methods, 260

DirectoryInfo.GetFiles() method, 597

disabling parallelism, 802

disambiguating multiple Main() methods, 174

Dispose() method, 6n6, 413, 416, 575

tasks, 770

distinct members, 631632

Distinct() method, 608, 613

distribution, APM parameters, 911

division (/) operators, 87

DLL (Dynamic Link Library), 4

COM registration, 890

do/while loops, control flow statements, 127129

documents

saving, 706708

XML, 402407, 678

domains, applications, 887

dot (.) operator, 871

DotGNU, 878

dotPeek, 30

double quotes ("), 47

double.TryParse() method, 207

downloading .NET (Microsoft), 897899

drivers, devices, 886

duck typing, 576

Dump() method, 325

Dynamic Link Library. See DLL

dynamic objects

behaviors/principles, 716718

binding, 719720

CIL, 718719

customizing, 721724

programming, 714724

reflection, invoking, 714716

static compilation versus, 720721

dynamic programming, 677

EAP (Event-based Asynchronous Pattern), 924927

editors, code, 151152

elements

deleting, 641

indexes, retrieving, 640

XML, runtime binding, 719720

#elif preprocessor directive, 146147

else clauses, 107

#else preprocessor directive, 146147

empty catch blocks, 432. See also catch blocks

empty collections, 659660

empty memory, retrieving, 246

Empty<T> method, 659

encapsulation, 211, 215

APIs, 859860

circumventing, 883

classes, 267269

publishers, 549550

subscribers, 548549

of types, 396

encryption. See also security

serialization, 708

strings, 804

EndGetResponse() method, 908

#endif preprocessor directive, 146147

#endregion preprocessor directive, 151152

EndX() method, 908

Enqueue() method, 654

Enter() method, 353

EntityBase, EntityBase<T> class, 468, 471

EntityDictionary, EntityDic-tionary<T> class, 469, 476

enumeration, values, 702

enums, 358368

Enum.Parse() method, 363, 680

flags, 364368

string conversions, 362364

type compatibility, 361362

equality, 93. See also inequality

dictionaries, customizing, 649650

operators, 115116

structural, delegates, 516517

Equals() method, 349, 651

overriding, 376385

equals (==) operator, 386

#error preprocessor directive, 148150

errors

arrays, 72, 8182

buffer overrun, 76

handling

platform interoperability/unsafe code, 854856

sequential notification, 544547

using statements, 575

infinite recursion, 186

methods, 194208

namespace alias qualifiers, 401

operators, 115

preprocessor directives, 148150

reporting, 204207

rounding, 37

trapping, 195201

Windows Error Reporting, 425

escape sequences, 44

verbatim string literals, 47

Etch A Sketch, 444

evaluation, 89

order of operands, 90

Event-based Asynchronous Pattern. See EAP

event keyword, 550, 551

events, 533534

CIL code, 556557

code conventions, 552554

declaring, 550551

delegates, 554555

invoking, 537538

operators, 540542

sequential invocation, 542

generics, 554555

handlers

adding, 846848

removing, 846848

implementing, customizing, 558559

internals, 556558

multicast delegates, 534548

notifications

firing, 553

multiple threads, 826827

null, checking for, 538539

publishers

connecting subscribers and, 536537

defining, 536

resetting, 831837

WinRT, 846848

examples of iterators, 666667

exceptions

AggregateException, 547, 757764, 768

parallel loop exception handling, 798800

ArgumentException, 424

ArgumentNullException, 424

ArgumentOutOfRangeException, 424

asynchronous high-latency operations, 775776

catching, 196197, 426427

classes, inheritance, 201

common exception types, 202

constructors, 418, 437

defining custom exceptions, 435438

handling, 423

general catch blocks, 428432

guidelines, 432435

multiple exception types, 424425

hiding, 432

InnerExceptions property, 760

InvalidAddressException, 435

InvalidCastException, 353, 464

InvalidOperationException, 427, 439

NotImplementedException, 321

NullReferenceException, 424, 538, 551, 659, 826

OperationCanceledException, 807

OutOfMemoryException, 433

reporting, 433

rethrowing, 206, 438442

sequences, diagrams, 545

serializable, 438

specifiers, 427

SqlException, 437

StackOverflowException, 433

suffixes, 437

System.ComponentModel.Win32Exception, 854

System.FormatException, 198, 199

System.InvalidCastException, 393

System.Runtime.Serialization.Serialization-Exception, 710

TaskCancelledException, 767, 768

ThreadAbortException, 741, 742

throwing, 195, 204205, 321

arrays, 75

checked/unchecked conversions, 63

deserialization, 711

UnauthorizedAccessException, 438

unhandled, 195, 761764

wrapping, 438442

excluding code, preprocessor directives, 146147

exclusive OR (^) operator, 118, 122

execution

agents, 881

deferred

implementing, 623

query expressions, 619

standard query operators, 586590

delegates, unsafe code, 872873

managed, 881

managing, 2426

Exit() method, 353

explicit conversions, 392

explicit deterministic resource cleanup, 216

explicit member implementation, 322323

exponential notation, 40

expressions

Boolean, 107, 114121

constants, 102103

generics, 6n6

lambda, 495, 506512

asynchronous programming, 782783

expression trees, 524

internals, 517518

lazy loading, 420

statements, 507510

queries

continuation, 629630

filtering, 623624

flattening sequences, 630622

grouping, 626629

invoking methods, 632634

let clause, 625626

LINQ, 561, 613

overview of, 614632

projecting, 616619

sorting, 624625

trees, 496, 523530

Extensible Markup Language. See XML

extensions

methods, 265266

IEnumerable<T> interface, 562

inheritance, 287

interfaces, 330331

Reactive Extensions library, 729

external functions

declaring, 849850

P/Invoke, calling, 858861

f-reachable queues, 416

factory interfaces, 475

factory methods, 461

FCL (Framework Class Library), 892, 895

features, adding, 278. See also inheritance

Fibonacci numbers/series, 128, 351

fields, 51

backing, declaring, 232, 244

constants, declaring, 267

guidelines, 234235

instances, 217219

readonly modifiers, declaring, 268, 269

static, 256258

virtual, properties, 240242

volatile, declaring as, 823824

FileInfo object, 625626

files

data

persistence to, 224

retrieval from, 225

headers, 168

loading, 224

metadata, 892893

references, assemblies, 889

storing, 224

XML, 23, 402407. See also XML

FileSettingsProvider, 329

FileStream property, 419

filtering

collections, 614

query expressions, 623624

System.Linq.Enumerable.Where(), 568569

WHERE clause, 623624

finalizers, 249250, 347, 410412

finally blocks, 199200

FindAll() method, 645

firing events, 548, 553

first in, first out (FIFO), collections, 654

fixed statements, 867, 868

flags

enums, 364368

values, 702

FlagsAttribute class, 367, 701702

flattening sequences, 630622

floating-point types, 3536, 9296, 351

flow control, 730. See also control flow statements

for loops, 120133

foreach loops, 133136

arrays, 571572

IEnumerable<T> interface, 572577

ForEach() method, 801

foreground threads, 739

formal declaration, methods, 165166

format items, 20

Format() method, 48

format strings, 20

formatting

comments, 2123

if/else statement sequences, 109

indentation, code blocks, 111

numbers as hexadecimal, 41

round-trip, 4243

string length, 51

variables, 15

whitespace, 1213

forms, Windows Forms, 932934

FORTRAN, 890

fractions, 35

fragile base classes, 295

frames, removing activation, 175

Framework (Microsoft .NET), 878

Framework Class Library. See FCL

frameworks, 877

FROM clause, 615

from clause, flattening sequences, 630632

FromCurrentSynchronizationContext() method, 788

full outer joins, 594

functionality, CLI, 888n5

functions

external

declaring, 849850

P/Invoke, 858861

global, 256

pointers, 862

fundamental numeric types, 3443

garbage collection, 25, 215

.NET (Microsoft), 882883

resource cleanup, 415418

runtime, 881882

value types, 347

well-formed types, 407410

gating parallelism, 802

GC.ReRegisterFinalize() method, 419

general catch blocks, 203, 428432

general-purpose delegates, System.Func/System.Action, 514530

generating

anonymous types, 568

XML documentation files, 405407

generics, 443

arity, 460461

benefits of, 452453

C# without, 444449

CIL, 490491

classes, 450452

collections, interface hierarchies, 637

constraints, 462476

constructors, defining, 457

contravariance, 481489

covariance, 481489

default values, specifying, 458459

delegates, declaring types, 552

events, 554555

expressions, 6n6

finalizers, defining, 457

instantiation

reference types, 492493

value types, 491492

interfaces, 454455, 456457

internals, 489493

Java, 493

lazy loading, 420

methods, 476481

casting inside, 480481

type inference, 478479

multiple type parameters, 459460

nested types, 461462

structs, 454455

types, 449462, 686688

GetCustomAttributes() method, 694

GetDynamicMemberNames() method, 724

GetEnumerator() method, 576, 577, 610, 661, 662, 664, 787n8

GetFiles() method, 157

GetFirstName() method, 232

GetFullName() method, 166

GetGenericArguments() method, 687

GetHashCode() method, 349, 373376, 651

GetInvocationList() method, 547, 548

GetLength() method, 79

GetName() method, 219

GetResponse() method, 772

GetResponseAsync() method, 779

GetReverseEnumerator() method, 673

GetSetting() method, 327

GetSummary() method, 305

GetSwitches() method, 696

getters, 51

access modifiers, 239240

accessibility, modifying, 237239

declaring, 230

GetType() method, 679680

GetUserInput() method, 166

GetValue() method, 685

GhostDoc, 406n3

global functions, 256

global methods, 164

global variables, 256

goto statements, 143145

graphs, expression trees, 525527

GreaterThan method, 507

groupby clause, 627

GroupBy() method, grouping results, 600601

grouping

encapsulation, 215

methods, 502

namespaces, 158

query expressions, 626629

results, 600601

statements into methods, 156157

types, defining namespaces, 398402

GroupJoin() method, 613

guest computers, 872

guidelines

addition (+) operators, 91

anonymous methods, 513

attributes

assemblies, 692

AttributeUsageAttribute class, 700

constructors, 699

custom, 693

catch blocks, 204

classes

access modifiers, 240

naming, 8, 214

collections, 649

comments, 23

constants, fields, 267

constructors

defaults, 248

naming, 251

conversion operators, 393

Count() method, 586

covariance, 489

curly braces ({}), 112

custom collections, 643

delegates, types, 515

empty collections, 660

Equals() method, 385

events, declaring, 554

exceptions

customizing, 437

handling, 207, 432435

multiple exception types, 425

reporting, 435

throwing, 106, 201

wrapping, 439

extension methods, 266

fields, 234235

finalizers, 417

floating-point types, 93, 95

generics

implementing multiple interfaces, 457

methods, 481

type parameters, 462

goto statements, 145

identifiers, 7

if/else statements, 120

increment/decrement operators, 101

integers, 35

interfaces

adding members, 335

attributes, 338

comparing to classes, 337

explicit/implicit implementations, 324325

implementations, 326

multiple inheritance, 333

naming, 315

lambda parameters, 509

literal suffixes, 40

local variables, 15

locking, avoiding, 823

long-running tasks, 770

for loops, 132, 133

managed wrappers/unmanaged methods, 856

methods, naming, 157

multiple type parameters, 460

multithreading, 733, 736

aborting threads, 743

thread pools, 745

Thread.Sleep() method, 741

unhandled exceptions, 764

namespaces, 161, 401

nested classes, 272

.NET (Microsoft), 6

null, invoking delegates, 539

OrderBy()/ThenBy() methods, 592

P/Invoke, 862

parallel loops, 797

parameters, 166, 191, 192

parentheses (()), 90

properties, 234235

get-only, 239

validating, 237

query expressions, 634

static initialization, 262

switch statements, 137

synchronization, avoiding, 823

System.EventHandler<T> class, 555

thread synchronization, 811841

best practices, 827829

Monitor, 817819

ToString() method, 373

types, naming parameters, 453454

value types

avoiding mutable types, 355

creating enums, 361

defaults, 347

defining structs, 369

direct enum/string conversions, 365

enum underlying types, 360

flag enums, 366

immutable, 345

memory, 341

overloading equality operators, 349

XML comments, 407

Handle() method, 760

handlers, events

adding, 846848

removing, 846848

handling

aliasing, 697699

errors

platform interoperability/unsafe code, 854856

sequential notification, 544547

using statements, 575

exceptions, 423

asynchronous high-latency operations, 775776

avoiding, 206207

background worker patterns, 931932

catching, 426427

defining custom exceptions, 435438

general catch blocks, 428432

guidelines, 432435

multiple exception types, 424425

rethrowing, 438442

wrapping, 438442

exceptions, parallel loops, 798800

hard coding values, 3840

hash codes, 651

headers, files, 168

heaps

memory, 349

reference types, 59, 342

Heater objects, 534535

HelloWorld program, 1, 24

output, 2930

static keyword, 255

Help property, 689

hexadecimal notation, 4041

hiding exceptions, 432

hierarchies

classes, 212, 324

interfaces, generic collections, 637

organizing, 161

high-latency operations, invoking, 771772, 772777

hill climbing, 798

hot tasks, 748. See also tasks

Hyper-Threading, 730

I/O-bound latency, 728, 732

IAngle.MoveTo interface, 354

IAsyncAction<T> interface, 848, 849

ICollection<T> interface, 638

IComparable interface, 323, 324

IComparable<T> interface, constraints, 465

IComparer<T> class, 495

identifiers, 67

keywords as, 8

namespaces, nesting, 400

IDictionary<T> interface, 636638

IDisposable interface

finalization, 415418

resource cleanup with, 413

tasks, 770

IDispose() method, 915

IDistributedSettingsProvider interface, 335

IEnumable<T> interface, 571577

IEnumerable interface, 331

IEnumerable<T> interface, 616n1

extension methods, 562

query expressions, 616

standard query operators, 577610

if/else statements, guidelines, 120

#if preprocessor directive, 146147

if statements, 80, 107110

Boolean expressions, 114121

IFileCompression interface, 314, 315

IFormattable interface, 357

ILDASM, CIL, 2829

IListable interface, 331

IList<T> interface, 636638

ILMerge utility, 889

ILSpy, 30

immutable strings, 17, 51, 52

modifying, 869870

implementation-defined behavior, 101

implementing

CIL, outer variables, 520521

CLI, 877878

conversion operators, 392

deferred execution, 623

dynamic objects, 714

Equals() method, 382

events, customizing, 558559

GetHashCode() method, 375376

interfaces, 313315, 316319, 320326, 456457

members

explicit, 322323

implicit, 323326

multiple inheritance, interfaces, 331334

new operator, 246

object-oriented programming, 210213

one-to-many relationships, 601604

outer joins, 603604

properties, automating, 232234

System.Runtime.Serialization.ISerializable class, 709710

implicit base type casting, 281

implicit conversions, 64, 392

implicit deterministic resource cleanup, 216

implicit local variables, 562568

implicit members, implementing, 323326

implicit nondeterministic resource cleanup, 216

implicit overriding, Java, 292

implicitly typed local variables, 5557

in type parameter, 485488

including code, preprocessor directives, 146147

Increment() method, 825

increment (++) operators, 97102

indenting

code blocks, 111

whitespace, 12

IndexerNameAttribute, 657

indexers

assigning, 657658

collections, 655659

indexes, retrieving elements, 640

IndexOf() method, 643

inequality, floating-point types, 9396

inferences, types, 478479

infinity

negative, 96

recursion errors, 186

infrastructure, CLI, 875877. See also CLI

inheritance, 211212, 277, 310311

abstract classes, 302308

aggregation, 289

base classes

base member, 300301

new modifier, 295299

overriding, 290302

sealed modifiers, 299301

chaining

casting, 282283

exceptions, 437

classes, exceptions, 201

constraints, 471472

definitions, 277278

derivation, 278290

casting between types, 281282

customizing conversions, 283283

private access modifiers, 284285

protected access modifiers, 285286

extension methods, 287

interfaces, 326329

multiple, 329330, 331334

value types, 348349

is operator, verifying underlying type, 309310

multiple, 287

polymorphism, 306

sealed classes, 290

single, 287289

System.object, deriving classes, 308309

virtual modifiers, 290295

initialization

anonymous types, arrays, 570571

centralizing, 252253

clauses, 132

collection initializers, 568571

lazy, 419421

NextId, 261

static, 262

static fields, 257

structs, 346347

Initialize() methods, 236

initializers

common, 249

constructors, 251

objects, 247248

initializing attributes, constructors, 694699

inner classes, Java, 272

inner joins, 593

Join() method, 597600

InnerExceptions property, 437, 439, 760

input, consoles, 1719

inserting newline ( ) characters, 46

installing .NET (Microsoft), 897899

instances

applications, formatting single, 829830

delegates, returning, 539

fields, 217219. See also static fields

methods, 48, 7879, 219220

polymorphism, 321

instantiation, 10

arrays, 7074

classes, 213216

delegates, 500502

generics

reference types, 492493

value types, 491492

integers, 3435

42 as, 195

adding, 351

values, overflowing, 62, 440

integral types, 91

IntelliSense, enabling, 615

interfaces, 313315

APIs, 27, 438, 439

attributes, comparing, 337338

automatically shimmed, 848

classes

comparing, 336337

conversions, 326

collection, 561562, 636638

anonymous types, 562564

implicit local variables, 564565, 566568

constraints, 465467

diagrams, 333334

extension methods, 330331

factory, 475

generics, 454455, 456457

hierarchies, generic collections, 637

IAngle.MoveTo, 354

IAsyncAction<T>, 848, 849

ICollection<T>, 638

IComparable, 323, 324

IComparable<T>, 465

IDictionary<T>, 636638

IDisposable

finalization, 415418

resource cleanup with, 413

tasks, 770

IEnumable<T>, 571577

IEnumerable, 331

IEnumerable<T>

extension methods, 562

query expressions, 616

standard query operators, 577610

IFileCompression, 314, 315

IFormattable, 357

IList<T>, 636638

implementing, 316319, 320326

inheritance, 326329

multiple, 329330, 331334

value types, 348349

IObsolete, 338

IOrderedEnumerable<T>, 592

IQueryable<T>, 609610

IReadOnlyPair<T>, 484

ISerializable, 709

ITrace, 325

multithreading, prior to TPL and C# 5.0, 907936

naming, 315

PairInitializer<T>, 487

parameters, 192

polymorphism, 315320

versioning, 334336

Windows UIs, 790792, 932936

internal access modifier, 397

internals

anonymous methods, 517518

delegates, 503506

events, 556558

generics, 489493

lambda expressions, 517518

multicast delegates, 542544

interoperability, 25

CIL, 890. See also CIL

languages, 25

platforms, 845846, 862872

Intersect() method, 608

into keyword, 629630

InvalidAddressException, 435

InvalidCastException, 353, 464

InvalidOperationException, 427, 439

Invoke() method, 685, 932

InvokeRequired property, 932

invoking

asynchronous delegate invocation, 921924

asynchronous tasks, 747748

delegates

events, 537538

exception sequence diagrams, 545

pass-by references, 547548

returning methods, 547548

sequences, 542

thread-safe, 539540

finalizers, 412

high-latency operations, 771777

members, reflection, 681686

methods, query expressions, 632634

reflection, dynamic objects, 714716

type members, 678. See also reflection

IObsolete interface, 338

IOrderedEnumerable<T> interface, 592

IProducerConsumer-Collection<T> class, 835

IQueryable<T> interface, 609610

IReadableSettingsProvider interface, 327

IReadOnlyPair<T> interface, 484

is operator, verifying underlying types, 309310

IsAlive property, 740

IsBackground property, 739

IsCancellationRequested property, 766, 767, 801

IsCompleted property, 750, 804

ISerializable interface, 709

ISettingsProvider interface, 327

IsKeyword() method, 620

items

collections, searching, 645

counting, 585586

format, 20

grouping, 600601

Items property, 456

iterations

collection interfaces, 573

continue statements, 141

long-running loops, 802

loops, 129, 794804

iterators

collections, 660674

compiling, 671672

contextual keywords, 672673

creating multiple in single classes, 673674

defining, 661

examples of, 666667

state, 664666

struct versus class, 670

syntax, 661662

yield break statements, 670671

yield return statements, 674

yielding values, 662664

recursive, 669

ITrace interface, 325

IWriteableSettingsProvider interface, 329

jagged arrays, 73, 75

Java, 1

arrays, declaring, 69

classes, naming, 4

exceptions, specifiers, 427

generics, 493

implicit overriding, 292

inner classes, 272

Main method, 10

virtual methods, 291

JavaScript, implicitly typed variables, 565

jitting, 879

Join() method, 739, 748

inner joins, 597600

joining

collections, 593

data types, 57

jump statements, 139145

break statements, 139141

continue statement, 141143

goto statement, 143145

just-in-time compilation, 24, 466, 879

JustDecompile, 30

keys, 637

keywords, 2, 46

into, 629630

async, 777781, 937942

await, 741, 777781, 937942

class, constraints, 468

contextual, iterators, 672673

default, 68

delegate, 542

event, 550, 551

as identifiers, 8

integers, 34

lock

applying, 819821

selecting objects, 821822

new, 71, 205

null, 5354

operator, 392

override, 292, 323

private, 229

properties, defining, 232

static, 264

string, avoiding locking, 822823

struct, 343, 468

this, 220227

avoiding locking, 822823

chaining constructors, 251253

try, 197

typeof, 363, 822823

unchecked, 442

void, 53, 5455

where, 465

lambda expressions, 495, 506512

asynchronous programming, 782783

expression trees, 524

internals, 517518

lazy loading, 420

statements, 507510

tables, 511512

languages

CIL, 876

CLI. See CLI

CLR, 881

CLS, 25, 891892

CLU, 660

COBOL, 890

FORTRAN, 890

overview of, 12

Pascal, 7

source, 890

XML, 2324. See also XML

last in, first out (LIFO), 444, 652

LastIndexOf() method, 643

late binding, 893

latency, 728

invoking high-latency operations, 771777

lazy initialization, 419421

left outer joins, 593

length

arrays, 7576

strings, 51

let clause, 625626

libraries

assemblies, 394

ATL, 287

BCL, 25, 26, 34, 885, 892, 894

classes, 394

code, creating, 4

DLL, 4

FCL, 892, 895

Reactive Extensions library, 729

Task Parallel Library (TPL), 729, 790. See also TPL

WinRT, 846849

limitations, constraints, 472473

line-based statements (Visual Basic), 11

#line preprocessor directive, 150

lines, specifying numbers, 150

linked lists, collections, 654655

LinkedListNode<T> class, 655

LinkedList<T> class, 654655

links, DLL, 4

LINQ

expression trees, 527

providers, customizing, 609

queries. See also queries

expressions, 561, 613

running in parallel, 584585, 804808

support, 27

Linux, installing platforms, 898

Liskov, Barbara, 660

listings

anonymous methods, passing, 512

APM patterns

accessing user interfaces, 933934

asynchronous delegate invocation, 922923

background worker patterns, 928929

ContinueWith() method, 919

EAP, 926927

invoking user interface objects, 935936

invoking with callback/state, 911912

passing state, 913914

System.Net.WebRequest class, 908909

using TPL to call, 915918

arrays

accessing, 74

assigning, 70

command-line options, 80

declaring, 69

defining size at runtime, 72

errors, 72

initializing two-dimensional arrays of integers, 72

jagged, 73, 75

length, 75, 76

literal values, 71

methods, 77

new keyword, 71

retrieving dimension size, 79

reversing strings, 8081

swapping data, 74

three-dimensional, 73

throwing exceptions, 75

two-dimensional arrays, 69, 72, 7475

attributes

applying named parameters, 700

assembles within AssemblyInfo.cs, 690691

AttributeUsageAttribute, 699700

backward compatibility, 712

constructors, 695

decorating properties with, 689, 690

defining custom, 693

FlagsAttribute class, 701702

implementing System.Runtime.Serialization.ISerializable class, 709710

restricting constructs, 699

retrieving custom, 693694

retrieving specific attributes, 695696

saving documents, 706708

specifying return attributes, 691

System.AttributeUsage-Attribute class, 699700

System.ConditionalAttribute class, 703705

System.ObsoleteAttribute class, 705706

System.SerializableAttribute class, 713

updating CommandLineHandler.TryParse(), 697699

break statements, 139140

case-sensitivity of multiple strings, 43

checked blocks, 6263

classes

access modifiers, 229

accessing fields, 218, 219220

accessing static fields, 257258

assigning static fields at declaration, 257

automatically implemented properties, 233234

avoiding ambiguity, 221222

calling constructors, 245246, 251252

calling object initializers, 248, 249

CIL code from properties, 243244

data persistence to files, 224

data retrieval from files, 225

declaring, 8

declaring constant fields, 267

declaring fields, 217

declaring getter/setter methods, 230

declaring static classes, 263264

declaring static constructors, 261

declaring static fields, 256

declaring static properties, 262

declaring variables of class types, 214

defining, 213

defining constructors, 245

defining nested classes, 270271, 273, 274275

defining partial classes, 272273

defining properties, 231, 240242

defining read-only properties, 238

defining static methods, 259260

explicit construct properties, 244

implicit local variables, 254

initialization methods, 253

instantiation, 215

overloading constructors, 250

passing this keyword in method calls, 223

placing access modifiers on setters, 239240

readonly modifiers, 268, 269

setting initial values of fields, 217

this keyword, 220221, 222

validating properties, 236

code blocks

if statements, 110

indentation, 111

collection interfaces

filtering with System.Linq.Enumerable.Where(), 568569

foreach with arrays, 572

implicit local variables with anonymous types, 562563

initializing anonymous type arrays, 570571

iterating, 573

resource cleanup with using statements, 575

results of foreach, 575576

separate enumerators during iteration, 574575

type safety, 566567

comments, 21

continue statement, 141143

control flow statements

do/while loops, 129

foreach loops, 134

if/else formatted sequentially, 109

if/else statements, 107

if statements, 135

multiple expressions (for loops), 132

nested if statements, 108

while loops, 127

custom collections

adding items to Diction-ary<T> class, 647

applying Pair<T>.Get-Enumeator() method, 667

applying yield statements, 666

bitwise complement () operator, 644

compiling iterators, 671672

defining index operators, 658659

defining indexers, 655657

FindAll() method, 645

implementing IComparer<T> interface, 642

implementing IEquality-Comparer<T> interface, 650

inserting items to Dictionary<T> class using index operators, 647

iterating over Dictionary<T> class with foreach, 648649

iterator interface patterns, 661662

List<T> class, 640

modifying indexer default names, 658

yield break statements, 670671

yield return statements, 673

yielding C# keywords sequentially, 663664

delegates

applying method names as arguments, 501502

applying variance, 516517

BubbleSort() method, 496497

BubbleSort() method, ascending/descending, 497498

BubbleSort() method, parameters, 498499

capturing loop variables, 521522, 523

CIL code for outer variables, 520

CIL for lambda expressions, 517518

declaring Comparison-Handler, 501

declaring Func/Action, 514515

declaring nested types, 500

declaring types, 500

expression trees, 525

outer variables, 518519

passing as parameters, 502

viewing expression trees, 528530

dynamic objects

customizing, 721723

overriding members, 723724

runtime binding, 719720

equality operators, overriding, 376380

Equals() method, overriding, 383384

escape sequences, 44

events

applying assignment operators, 548

CIL code, 556557

connecting publishers/subscribers, 536537

custom add/remove handlers, 558

custom delegate types, 554555

declaring generic delegate types, 552

declaring OnTemperature-Change event, 556

defining Heater/Cooler objects, 534535

defining publishers, 536

delegate operators, 540, 541

event keyword, 550551

firing, 549

firing notifications, 553

handling exceptions from subscribers, 546547

invoking delegates, 537538

OnTemperatureChanged() method, 544

exceptions

catching, 426, 428431

checked blocks, 440441

customizing, 436

defining serializable, 438

overflowing integer values, 440

throwing, 424

unchecked blocks, 441442

explicit casts, 61

generics

arity, 460

BinaryTree<T> class, 462463, 480

CIL code for Stack<T> class, 490

CIL with Exclamation Point Notation, 491

combining constraints, 473474

combining covariance and contravariance, 487

ComparisonHandler, 504505

compile errors, 458

compiler validation of variance, 488

constraint expressions, 473

contravariance, 486

converting generics, 482

covariance, 482, 483484

covariance using out type parameter modifier, 484

Create() method, 461

declaring class type constraints, 467

declaring constructors, 457

declaring generic classes, Stack<T>, 452

declaring interface constraints, 465

declaring interfaces, 454

declaring nullable types, 449

declaring variables of type scatter<T>, 491

declaring versions of value types, 448

default constructor constraints, 470, 475

default operator, 458

defining methods, 477

defining specialized stack classes, 447

duplicating interface implementations, 456

EntityDictionary<T> class, 476

factory interfaces, 475

implementing interfaces, 455

implementing Undo with Stack class, 450451

inferring type arguments, 478

inheritance constraints, 474

inheritance constraints, specified explicitly, 471

interface support, 463

multiple constraints, 469

multiple type parameters, 459, 460

nested types, 462

repeating inherited constraints, 472

specifying constraints, 479480

specifying type parameters, 478

struct/class keywords, 468

supporting Undo, 444445

System.Collections.Stack method signatures, 444

System.Delegate class, 504

type parameter support, 464

GetHashCode() method, overriding, 375

goto statements, 143144

HelloWorld, 2

breaking apart, 9

output, 2930

hexadecimal notation, 41

implicit conversions, 64

implicit local variables, 5657

inheritance

accessing base members, 300

accessing private members, 284

accessing protected members, 285286

applying methods, 280

applying polymorphism, 306307

defining abstract classes, 303

defining abstract members, 303304

defining cast operators, 283

deriving classes, 279, 280

implicit base type casting, 281

is operator determining underlying type, 309

new modifier, 297298

as operator conversions, 310311

overriding properties, 291

preventing derivation, 290

Run() method, 294

sealing members, 299

single using aggregation, 288

specifying base constructors, 301302

System.Object derivation, 309

virtual methods, 292, 293

integers, overflowing values, 62

interfaces

applying base interfaces in class declarations, 328

calling explicit member implementations, 322

declaring explicit members, 327

defining, 315

deriving, 326327, 335

explicit interface implementation, 322323

implementing, 316319, 320321

multiple inheritance, 329

single inheritance using aggregation, 331332

lambda expressions

omitting parameter types, 508

parameterless statements, 509

passing delegates, 510

single input parameters, 509

statements, 507

literal values, 38, 39

for loops, 130

Main() method, 10

methods

aliasing, 171172

calling, 158

catching exceptions, 196197

converting a string to an int, 194

counting lines, 184185, 187189

declaring, 163164

finally blocks without catch blocks, 199200

general catch blocks, 203

grouping statements, 156157

optional parameters, 189191

passing command-line arguments, 173

passing return values, 162

passing variable parameter lists, 181182

passing variables by reference, 177178

passing variables by values, 175176

passing variables out only, 179180

rethrowing exceptions, 206

return statements, 167

specifying parameters by names, 191192

throwing exceptions, 204205

using directive, 170171

multiple statements on one line, 12

multithreading

applying Task.Factory.StartNew() method, 769

asynchronous Web requests, 773774, 777778

await keyword, 787788

calling Task.ContinueWith method, 752, 789

cancelling parallel loops, 800801

cancelling PLINQ queries, 807808

cancelling tasks, 765766

customizing asynchronous methods, 784785, 785786

handling tasks, unhandled exceptions, 758759

invoking asynchronous tasks, 747748

iterating over await operations, 792793

lambda expressions, 782783

LINQ Select() method, 804

long-running tasks, 769770

for loops, 794795, 796

observing unhandled exceptions, 760761

parallel execution of foreach loops, 797

PLINQ Select() method, 805

PLINQ with query expressions, 806

polling Task<T> classes, 749

registering for notifications, 756

registering for unhandled exceptions, 762763

starting methods, 737738

synchronous high-latency invocation with WPF, 791792

synchronous Web requests, 772773

ThreadPool, 743744

unhandled exception handling, parallel iterations, 799

character, 46

no indentation formatting, 12

nullable modifiers, 60

operators, 86

AND (&&), 118

binary, 8788

bitwise, 124

char data types, 92

character differences, 92

common increment calculations, 97

conditional, 119

constants, 103

decrement (- -), 98

dividing a float by zero, 95

equality, 116

examples of assignment, 97

increment (++), 97

inequality with floating-point types, 9495

logical assignment, 126

negative values, 87

non-numeric types, 91

NOT, 118

null coalescing, 120

overflowing bounds of float, 96

post-increment, 99

pre-increment, 99

prefix/postfix, 100

relational, 116

Unicode values in descending order, 98

Parse() method, 65

placeholders, 20

platform interoperability/unsafe code

accessing referent type members, 871872

allocating data on call stacks, 868

applying ref/out rather than pointers, 852

declaring external methods, 849850

declaring types, 853

designating unsafe code, 863, 872873

encapsulating APIs, 859860

fixed statements, 867, 868

invalid referent types, 866

managed resources, 857858

modifying immutable strings, 869870

SafeHandle, 856857

Win32 error handling, 854855

WinRT patterns, 847848

wrapping APIs, 861

#pragma preprocessor directive, 149

preprocessor directives, 147

#define, 147

excluding/including code, 147

#region/#endregion, 151

#warning, 148

query expressions, 614615, 632633

anonymous types, 618

continuation, 630

deferred execution, 619622

distinct members, 631632

filtering, 623624

grouping, 626627

multiple selection, 630

ordering results, 616

projection using, 617

selecting anonymous types, 628629

sorting, 624

sorting by file size, 625

standard query operator syntax, 633

reflection

declaring Stack<T> class, 686

dynamic programming using, 715

dynamically invoking members, 681684

generics, 687, 688

using Type.GetProperties() method, 679680

using typeof() method, 680

round-trip formatting, 42

single statements, splitting, 12

standard query operators

calling SelectMany() method, 604605

classes, 578580

counting items, 585

creating child collections, 602

executing LINQ queries in parallel, 584

filtering with System.Linq.Enumerable.Where() method, 581, 586587

grouping items, 600601

inner joins, 597598, 599

ordering, 590591

outer joins, 603604

projection to anonymous types, 583

projection with System.Linq.Enumerable.Select() method, 582

sample employee/department data, 594596

System.Linq.Enumerable() method calls, 606607

strings

applying, 5253

assigning null to, 54

binary displays, 125

immutable, 52

implicitly typed local variables, 5556

length, 51

switch statements, 137138

System.Console.ReadLine() method, 1718

System.Console.WriteLine() method, 1920

System.Convert class, 65

System.Threading.Timer class, 941942

System.Timers.Timer class, 939940

thread synchronization, 811841

best practices, 827829

creating single instance applications, 829830

firing event notifications, 826

lock keyword, 820

ManualResetEventSlim, 832833

Monitor class, 817818

System.Threading.Interlocked class, 824825

Task.Delay() method, 842

thread-safe event notification, 826

ThreadLocal<T> class, 838

ThreadStaticAttribute class, 839840

unsynchronized local variables, 815816

unsynchronized state, 813

Tic-Tac-Toe source code, 901905

timers, 939942

ToString() method, 65, 372373

unchecked blocks, 63

Unicode characters (smiley faces), 4546

value types

accessing properties, 346

avoiding copying/unboxing, 357

boxing idiosyncrasies, 353

boxing/unboxing instructions, 351

casting between arrays/enums, 362

comparing integer switches/enum switches, 358

converting strings to enums, 363

declaring enums, 359

declaring structs, 344345

default operator, 348

defining enum values, 366

defining enums, 359

enums as flags, 364

FlagsAttribute, 367

initializing structs, 346

OR/AND operators with flag enums, 365

referencing Equals() method, 381

unboxing to underlying types, 353

variables

assigning, 16

declaring, 13

modifying values, 15

one statement, declaring with, 15

scopes, 113

verbatim string literals, 47

well-formed types

adding operators, 387388

applying alias directives, 402

calling binary operators, 388

comparison operators, 386

conversion operators, 392

defining finalizers, 411

defining namespaces, 399

invoking using statements, 415

lazy loading properties, 419, 420

making types available, 396

nesting namespaces, 400

overloading unary operators, 390, 391

resource cleanup, 413

weak references, 409

XML comments, 403406

whitespace, removing, 12

lists

collections, 640

formal parameters, 165

linked, collections, 654655

type parameters, 165

List<T> class, 482, 639641

searching, 643644

literals

strings, 4648

values, 3738

arrays, 71

readonly fields, 269

loading

files, 224

lazy. See lazy initialization

local negation (!) operator, 118119

local storage, threads, 837841

local variables, 14

anonymous types, 562563

declaring, 165166

implicit, 564565, 566568

implicitly typed, 5557

multiple threads, 815816

scope, 114

locations

keywords, 4

objects, 408

reference types, 341345

lock keyword

applying, 819821

objects, selecting, 821822

lock statements, 736

value types, 353255

locking, 828829

avoiding, 822823

consoles, synchronization, 920921

multithreading, 736

lockTaken parameter, 819

logical Boolean operators, 116121, 122126

Logon() method, 228

long-running

loops, 802

tasks, 769770

loops

for, 120133

decrement (--) operators, 98

do/while, control flow statements, 127129

executing, iterations in parallel, 794804

foreach, 133136

arrays, 571572

IEnumerable<T> interface, 572577

iterations, 129

parallel

breaking, 803804

executing iterations in, 794804

options, 802803

variables, capturing, 521522

while, control flow statements, 127129

yield return statements, placing in, 667669

LowestBreakIteration property, 804

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.14.181.129