M

Main() method

activation frame, 182183

call site, 182183

call stack, 182183

declaring, 10

definition, 9

disambiguating multiple Main() methods, 182

invoking location, 183

multiple, disambiguating, 182

nonzero return code, 10

parameters, 180183

passing command-line arguments to, 180183

returns from, 180183

stack unwinding, 182183

syntax, 910

main() method, Java vs. C#, 10

__ makeref keyword, 8

MakeValue() method, 480

Managed code, definition, 26

Managed execution

BCL (Base Class Library), 27, 28

CIL (Common Intermediate Language), 2628

CLI (Common Language Infrastructure) specification, 2627

CLS (Common Language Specification), 27

code access security, 27

CTS (Common Type System), 27

definition, 26

execution time, 27

garbage collection, 28

just-in-time compilation, 26

language interoperability, 27

managed code, definition, 26

native code, definition, 26

platform portability, 28

runtime, definition, 26, 27

type safety, 27

unmanaged code, definition, 26

VES (Virtual Execution System), 26

Many-to-many relationships, definition, 604

Masks, 132

Max() method, 273275, 618

MaxDegreeOfParallelism property, 807

Max<T> method, 487489

mcs.exe compiler, 3

Me keyword, 230

Member invocation, reflection, 687692

Member names, retrieving, 729

Member variables, 225

MemberInfo, 691692

Memory, deallocating, 423. See also Garbage collector.

Metadata

about assemblies, adding, 697698

within an assembly, examining. See Reflection.

CIL (Common Intermediate Language), 894895

definition, 25

for types, accessing with System.Type, 685. See also Reflection.

XML, 25

Metadata tables, setting bits or fields in. See Pseudoattribute.

Method calls

avoiding boxing, 369370

during construction, C++ vs. C#, 307

as ref or out parameter values, 252

vs. statements, 169

translating query expressions to, 640641

Method group conversion, delegates, 512

Method names

as arguments, delegates, 511512

calling, 167

Method resolution, 201202

Method returns, multicast delegates, 558

MethodCallExpression, 535

MethodImplAttribute, 827

MethodImplOptions.Synchronized() method, 827

Methods. See also specific methods.

accessing by name, on interfaces, 336

class association, 163

declaring in interfaces, 327

definition, 9, 162163

derived from System.Object, 320321

global, C++ vs. C#, 171

guidelines for naming, 163

identifying support for generics, 692693

instance, 227228

naming conventions, 163

operational polymorphism, 195

overloading, 194197, 199

overriding, 304

partial, 285288

return type declaration, 172174

return values, 168169

syntax, 911

uniqueness, 195

void, 173174

Methods, calling

applicable calls, 201

arguments, 163, 167168

caller, 163

compatible calls, 201

method call example, 164

method name, 167

method resolution, 201202

method return values, 168169

named arguments, 199

namespaces, 164166. See also specific namespaces.

recursively. See Recursion.

return values, 163

scope, 167

statements vs. method calls, 169

type name qualifier, 166167

Methods, declaring

example, 169170

expression bodied methods, 174

formal parameter declaration, 171172

formal parameter list, 172

method return type declaration, 172174

refactoring, 171

return statement, example, 173

type parameter list, 172

void as a return type, 173174

Methods, extension

derivation, 299

on interfaces, 341343

overview, 275277

Microsoft IL (MSIL). See CIL (Common Intermediate Language).

Microsoft Silverlight compiler, 880

Miller, J., 26

Min() method, 273275, 618

Min(<T>) method, 487489

Minus sign (-)

arithmetic subtraction operator, 9192

delegate operator, 551552

precedence, 92

subtraction operator, overloading, 397399

unary operator, 9091

Minus sign, equal (-=)

binary/assignment operator, 399

delegate operator, 550552

Minus signs (--) decrement operator

C++ vs. C#, 105

decrement, in a loop, 102105

description, 101102

guidelines, 105

lock statement, 105106

postfix increment operator, 104105

post-increment operator, 103

prefix increment operator, 104105

pre-increment operator, 103104

race conditions, 105106

thread safety, 105106

Modules, referencing, 405

Monads, definition, 591

Monitor, 821823

Mono compiler, 3, 880

Montoya, Inigo, 2

Move() method, 276, 357

MoveNext() method, 672673

MSIL (Microsoft IL). See CIL (Common Intermediate Language).

MTA (Multithreaded Apartment), 846

Multicast delegates

adding methods to, 554

chaining, 555

definition, 543, 547

error handling, 554556

internals, 554

new delegate instances, 550

passing by reference, 558

removing delegates from a chain, 550552

Multidimensional arrays, 74, 7779

Multiple inheritance

C++ vs. C#, 299

simulating, 299301

Multiple inheritance, interfaces

aggregation, 343344

diagramming, 345

implementing, 341, 343344

working around single inheritance, 343344

Multiple Main() methods, disambiguating, 182

Multiplication with bit shifting, 130

Multithreaded Apartment (MTA), 846

Multithreaded programming complexities, 749750

Multithreaded programs, definition, 733

Multithreading

asynchronous operations, definition, 736

clock speeds over time, 732

concurrent operations, definition, 736

context switch, definition, 736

CPU (central processing unit), definition, 734

flow of control, definition, 734

Hyper-Threading, definition, 734

I/O-bound latency, definition, 732

latency, definition, 732

multithreaded programs, definition, 733, 734

parallel programming, definition, 736

PLINQ (Parallel LINQ), 733

process, definition, 734

processor-bound latency, definition, 732

purpose of, 735736

quantum, definition, 736

simultaneous multithreading, definition, 734

single-threaded programs, definition, 734

TAP (Task-based Asynchronous Pattern), 733

task, definition, 735

thread, definition, 734

thread pool, definition, 735

thread safe code, definition, 734

threading model, definition, 734

time slice, definition, 736

time slicing, definition, 736

TPL (Task Parallel Library), 733

Multithreading, asynchronous tasks

antecedent tasks, 757

associating data with tasks, 755

asynchronous continuations, 756762

chaining tasks, 757

cold tasks, 752

composing large tasks from smaller one, 756758

continuation tasks, 757

control flow, 755

creating threads and tasks, 750751

hot tasks, 752

Id property, 755

introduction, 751755

invoking, 751753

multithreaded programming complexities, 749750

observing unhandled exceptions, 764765

polling a Task<T>, 753754

registering for notification of task behavior, 760761

registering for unhandled exceptions, 766768

synchronous delegates, 751

task continuation, 755762

task identification, 755

task scheduler, 750751

task status, getting, 754

tasks, definition, 750

tasks vs. delegates, 751

unhandled exception handling with AggregateException, 762765

unhandled exceptions on a thread, 765768

Multithreading, canceling tasks

cooperative cancellation, definition, 769

disposable tasks, 774

long-running tasks, 773774

obtaining a task, 772773

Multithreading, guidelines

aborting threads, 747

long-running tasks, 773774

parallel loops, 801

performance, 737, 740

thread pooling, 749

Thread.Sleep() method, 745

unhandled exceptions, 768

Multithreading, parallel loop iterations

breaking, 808

canceling, 805806

exception handling with AggregateException, 803804

hill climbing, 802803

introduction, 798802

options, 806807

TPL performance tuning, 802803

work stealing, 802803

Multithreading, performance

context switching, 737

overview, 736737

switching overhead, 737

time slicing costs, 737

Multithreading, PLINQ queries

canceling, 811813

introduction, 809811

Multithreading, task-based asynchronous pattern

with async and await, 781786

async and await with the Windows UI, 795798

async keyword, purpose of, 786

asynchronous high-latency operations with the TPL, 777781

asynchronous lambdas, 786787

await keyword, 791792

await operators, 797798

awaiting non-Task<T> values, 791792

control flow misconceptions, 784

control flow within tasks, 784786

custom asynchronous methods, 787791

handling exceptions, 779780

progress update, 789791

synchronization context, 793795

synchronous high-latency operations, 775777

task drawbacks, overview, 775

task schedulers, 793795

Multithreading, threading problems

atomic operations, 738

complex memory models, 739

deadlocks, 740

lock statement, 740

locking leading to deadlocks, 740

race conditions, 738

Multithreading, with System.Threading.Thread

Abort() method, 745746

aborting threads, 745746

asynchronous delays, 745

asynchronous operations, 741743

await operator, 745

checking threads for life, 744

foreground threads vs. background, 743

IsAlive property, 744

IsBackground property, 743

Join() method, 743744

Priority property, 743

putting threads to sleep, 744

reprioritizing threads, 743

Task.Delay() method, 745

thread management, 743744

thread pooling, 747749

ThreadAbortException, 745746

Thread.Sleep() method, putting threads to sleep, 744

ThreadState property, 744

waiting for threads, 743

N

, newline character, 46, 48

Name property, 249250, 292, 297, 302303

Named arguments, calling methods, 199

Named parameters, attributes, 707

nameof operator

properties, 246247

throwing exceptions, 435, 436

Namespaces

alias qualifier, 412413

aliasing, 179180. See also using directive.

calling methods, 164166

in the CLR (Common Language Runtime), 410

common, list of, 165166

defining, 409410

definition, 164, 175

dropping. See using directive.

eliminating. See using directive.

extern alias directive, 413

guidelines, 166, 412

importing types from. See using directive.

introduction, 409410

namespaces alias qualifier, 412413

naming conventions, 166, 410

nested, 176, 411

Naming conventions

class definition, 8

identifiers, 67

interface guidelines for, 327

local variables, 15

methods, 163

namespaces, 166, 410

parameters, 172, 200

properties, 243

type parameter, 465466

Native code, definition, 26

NDoc tool, 418

Nested

classes, 281283

delegates, 510

generic types, 472473

if statements, 112113

iterators, 676

namespaces, 176, 411

types, 283

using directives, 177178

.NET

definition, 895

garbage collection, 418419, 884885

.NET Compact Framework compiler, 880

.NET Micro Framework compiler, 880

.NET versions, mapped to C# releases, 29

New line, starting

/n (newline character), 46, 48, 55

strings, 46, 48

verbatim string literals, 49

WriteLine() method, 55

new modifier, 307311

new operator

constructors, 256

value types, 359360

NewExpression, 535

NextId initialization, 271273

Non-nullable value types, 478479

No-oping a call, 710711

Normalized data, 607608

NOT operator, 122

NotImplementedException, 210

NotOnCanceled enum, 759

NotOnFaulted enum, 758

NotOnRanToCompletion enum, 758

nowarn option, 157

Nowarn:<warn list> option, 157

null, checking for

empty arrays or collections, 666667

guidelines, 549

multicast delegates, 548549

null type

assigning value types to, 6465

description, 5859

use for, 58

NullReferenceException

invoking delegates, 562

throwing exceptions, 434, 436

Numbers, formatting as hexadecimal, 43

Numeric conversion, exception handling, 215216

O

Object graphs, expression trees as, 535536

Object initializers

calling, 257259

constructors, 257259

definition, 257

object members, overriding, 388395

Object-oriented programming, definition, 218219

Objects. See also Constructors.

associations, 269

CTS types, 892

definition, 222223

destroying, 259

identity vs. equal object values, 388392

instantiation, 222223

Observer pattern. See Coding the observer pattern with multicast delegates.

Obsolete APIs. See Deprecated APIs.

Obtaining a task, 772773

OfType<T>() method, 618

One-to-many relationships, 604, 611613

OnFirstNameChanging() method, 287

OnLastNameChanging() method, 287

OnlyOnCanceled enum, 758

OnlyOnFaulted enum, 759

OnlyOnRanToCompletion enum, 759

OnTemperatureChange event, 566

OnTemperatureChange() method, 567568

OnTemperatureChanged() method, 545546

Operands, 90

Operational polymorphism, 195

OperationCanceledException, 772, 806, 811813

Operator constraints, constraint limitations, 482483

Operator keyword, 402

Operator order of precedence, C++ vs. C#, 105

Operator-only statements, C++ vs. C#, 91

Operators. See also specific operators.

arithmetic binary (+, -, *, /, %), 9192, 95

associativity, 92, 9394

characters in arithmetic operations, 96

comparison, 396397

compound assignment (+=, -=, *=, /=, %=), 100101

const keyword, 106107

constant expressions, 106107

constant locals, 106107

definition, 89

left-associative, 93

operands, 90

operator-only statements, C++ vs. C#, 91

order of operations, 92, 94

plus and minus unary (+, -), 9091

precedence, 92, 9394, 160

results, 90

right-associative, 93

Operators, increment/decrement (++, --)

C++ vs. C#, 105

decrement, in a loop, 102105

description, 101102

guidelines, 105

lock statement, 105106

postfix increment operator, 104105

post-increment operator, 103

prefix increment operator, 104105

pre-increment operator, 103104

race conditions, 105106

thread safety, 105106

Optional parameters, 197198

OR criteria, constraint limitations, 483

Order of operations, 92, 94. See also Precedence.

orderby clause, 632633

OrderBy() method, 601603

OrderByDescending() method, 602

out, passing parameters, 186188

out modifier, 492494

out parameter, properties as values, 252

Out property, 700

out vs. pointers, P/Invoke, 853854

Outer joins, 613616

Outer variables, lambda expressions, 528530

OutOfMemoryException, 435, 444

Output, passing parameters, 186188

Overloading. See also Overriding.

== (equal signs) equality operator, on value types, 362

!= (exclamation point, equal sign) inequality operator, on value types, 362

cast operator, 402

constructors, 259261

equality operators on value types, 362

Equals() method, 362

methods, 194197

type definitions, 471472

Overloading, object members

Equals() equality operator, 388395

GetHashCode() method, 385387

ToString() method, 384385

Overloading, operators

binary operators, 397399

binary operators combined with assignment operators, 397399

cast operator, 402

conditional logical operators, 400

conversion operators, 401, 403

unary operators, 400401

override keyword, 304, 313

Overriding. See also Overloading.

abstract members, 317

base classes. See Base classes, overriding.

base classes, virtual methods, 302307

implicit, C++ vs. C#, 304

methods, 304

properties, 303

P

PairInitializer<T> interface, 497

Pair<T>, 492

Palindromes, 8486

Parallel LINQ (PLINQ) queries, multithreading

canceling, 811813

introduction, 809811

Parallel loop iterations. See Multithreading, parallel loop iterations.

Parallel programming, definition, 736

Parallel.For() loops, 807

Parallel.For() method, 808

Parallel.ForEach() loops, 807

Parallel.ForEach() method, 808

ParallelOptions parameter, 807

ParallelQuery<T>, 810, 813

Parameter arrays, 189191

Parameter types

determining, 692

explicitly declared, 518

P/Invoke, 851853

ParameterExpression, 535

Parameterized types, 461

Parameters

calling methods, 163, 167168

guidelines, 172, 199200

on the Main() method, 180183

matching caller variables with parameter names, 184

method overloads, 199

names, generating. See Nameof operator.

names, obtaining, 696

naming conventions, 172, 200

optional, 197198

reference types vs. value types, 184185

specifying by name, example, 199200

Parameters, passing

out, 186188

output, 186188

ref type, 185186

by reference, 185186

by value, 183184

params keyword, 189191

Parent type, 220

Parentheses ( () )

for code readability, 9394

grouping operands and operators, 9394

guidelines, 94

Parse() method, 6970, 215216, 376, 709

Partial classes, 4, 284285

Partial methods, C++ vs. C#, 174

PascalCase, 67

Passing

anonymous methods, 522523

command-line arguments to Main() method, 180183

delegates with expression lambdas, 520

by reference, multicast delegates, 558

Passing, parameters

out, 186188

output, 186188

ref type, 185186

by reference, 185186

by value, 183184

PCLs (portable class libraries), 406

Peek() method, 661662

Percent sign, equal (%=) binary/assignment operator, 399

Percent sign (%) modulo, 9192, 397399

Performance

boxing, 365

effects of boxing, 365

locks, 825

multithreading, 736737, 740

runtime, 887888

TPL (Task Parallel Library), 802803

Periods (....), download progress indicator, 779

PiCalculator.Calculate() method, 753

PingButton_Click() method, 796

Ping.Send() method, 796

P/Invoke. See also WinRT.

allocating virtual memory, 852

calling external functions, 858860

declaring external functions, 850851

declaring types from unmanaged structs, 854855

description, 850

error handling, 855857

function pointers map to delegates, 861862

guidelines, 857, 862

out vs. pointers, 853854

parameter types, 851853

ref vs. pointers, 853854

SafeHandle, 857858

sequential layout, 854855

Win32 error handling, 855857

wrappers for API calls, 860861

Platform interoperability. See P/Invoke; Unsafe code; WinRT.

Platform portability, managed execution, 28

PLINQ (parallel LINQ) queries, multithreading

canceling, 811813

introduction, 809811

Plus sign (+)

addition operator, overloading, 397399

arithmetic binary operator, 9192

with char type data, 96

concatenating strings, 95

delegate operator, 551552

determining distance between two characters, 96

with non-numeric operands, 95

precedence, 92

unary operator, 9091

Plus sign, equal (+=)

binary/assignment operator, 399

delegate operator, 550552

Plus signs (++) increment operator

C++ vs. C#, 105

decrement, in a loop, 102105

description, 101102

guidelines, 105

lock statement, 105106

postfix increment operator, 104105

post-increment operator, 103

prefix increment operator, 104105

pre-increment operator, 103104

race conditions, 105106

thread safety, 105106

Pointers and addresses

accessing members of a referent type, 871

allocating data on the call stack, 868869

assigning pointers, 866869

dereferencing pointers, 869871

fixing (pinning) data, 866868

pointer declaration, 864869

referent types, 864

unmanaged types, 865

unsafe code, 862864

Polling a Task<T>, 753754

Polymorphism. See also Inheritance; Interfaces.

abstract classes, 318320

description, 221

interfaces, 327332

Pop() method, 456459, 661662

Portable class libraries (PCLs), 406

#pragma preprocessor directive, 153, 156157

Precedence, 92, 9394, 160. See also Order of operations.

Precision

binary floating-point types, 97

double type, 97

float type, 97100

Predefined attributes, 709

Predefined types, 3536

Predicates

definition, 520, 591

filtering class collections, 591

lambda expressions, 520, 631

PreferFairness enum, 758

Preprocessing, C++ vs. C#, 152

Preprocessor directives. See also Control flow; Flow control.

as comments, 154

as debugging tool, 154

defining preprocessor symbols, 155

disabling/restoring warning messages, 156157

emitting errors and warnings, 155156

excluding/including code, 154

handling differences among platforms, 154

specifying line numbers, 157

summary of, 152. See also specific directives.

visual code editors, 158159

Preprocessor symbols, defining with preprocessor directives, 155

The Princess Bride, 2

Print() method, 318

Priority property, 743

private access modifier, 235237, 296297

private accessibility modifier, 409

Private fields, 237238

Private keyword, 237

Private members

accessing, 296297

definition, 236

inheritance, 296297

Process, definition, 734

Process.Kill() method, 789

Processor-bound latency, definition, 732

Program

accessing fields, 226227

accessing static fields, 267268

code example, 398399, 405

defining properties, 240

Programming, object-oriented definition, 218219

Programming with dynamic objects

dynamic binding, 724725

dynamic directive, 721

dynamic member invocation, 722

dynamic principles and behaviors, 721723

dynamic System.Object, 723724

implementing a custom dynamic object, 726728

introduction, 719

invoking reflection with dynamic, 719720

reflection, support for extension methods, 723

retrieving member names, 729

signature verification, 722

vs. static compilation, 725726

type conversion, 721722

type safety, 720721, 726

Progress update display, 789791

Projecting collections

definition, 622

FileInfo collections, 633634

with query expressions, 624627

with Select(), 592594

Properties

automatically implemented, 240242, 248, 254, 273

automatically implemented, read- only, 280

declaring, 238240

decorating with attributes, 696697

definition, 238

guidelines, 242244, 248, 258

internal CIL code, 253254

introduction, 237238

nameof operator, 246247

naming conventions, 243

overriding, 303

read-only, 247248

read-only automatically implemen- ted, 280

as ref or out parameter values, 252

static, 273

validation, 244246

as virtual fields, 249250

write-only, 247248

protected access modifier, 297298

protected accessibility modifier, 409

protected internal accessibility modifier, 409

protected internal type modifier, 408

Protected members, accessing, 297298

Pseudoattributes, 719

public access modifier, 235237, 407409

Publishing code, checking for null, 548

Pulse() method, 823

Pure virtual functions, C++ vs. C#, 317

Push() method, 456459, 661662

Q

Quantum, definition, 736

Query continuation clauses, 637638

Query expressions with LINQ

code example, 622623

continuation clauses, 637638

deferred execution, 627631

definition, 621

discarding duplicate members, 639640

filtering collections, 631632

flattening a sequence of sequences, 638639

from clause, 623624

group by clause, 635637

group clause, 623

grouping query results, 634637

into keyword, 637

introduction, 622624

let clause, 633634

projecting collections, 624627

range variables, 622623

returning distinct members, 639640

select clause, 623624

sorting collections, 632633

translating to method calls, 640641

where clause, 623624

Query operators. See Standard query operators.

Question mark, colon (?:) conditional operator, 123124

Question mark, dot (?.) null-conditional operator, 125128

Question mark (?) nullable modifier, 6465, 459

Question marks (??) null-coalescing operator, 124125, 126

Queue collections, 662

Queue<T>, 662

R

Race conditions. See also Thread synchronization.

class collections, 595

threading problems, 738

Ragsdale, S., 26

Range variables, 622623

Rank, arrays

declaring, 72

getting the size of, 8384

Reactive Extensions, 816

Read() method, 19, 829830

Readability. See Code readability.

ReadKey() method, 19

ReadLine() method, 1819

Read-only

automatically implemented properties, 280

fields, encapsulation, 279281

properties, 247248

readonly modifier

encapsulation, 279281

guidelines, 281

ReadToAsync() method, 779

ReadToEnd() method, 776

ReadToEndAsync() method, 779

Recursion. See also Methods, calling.

definition, 192

example, 192193

infinite recursion error, 194

Recursive iterators, 676

ref parameter, properties as values, 252

ref type parameters, passing, 185186

ref vs. pointers, 853854

Refactoring

classes, 290291

methods, 171

Reference, passing parameters by, 185186

Reference types

constraints on type parameters, 478479

copying, 355

vs. value types, 184185, 353355

ReferenceEquals() method, 392

Referencing other assemblies

changing the assembly target, 404

class libraries, 404405

console executables, 404

encapsulation of types, 407408

internal access modifiers on type declarations, 407408

on Mac and Linux, 406

modules, 405

PCLs (portable class libraries), 406

protected internal type modifier, 408

public access modifiers on type declarations, 407408

referencing assemblies, 405406

referencing assemblies on Mac and Linux, 406

type member accessibility modifiers, 409

Windows executables, 405

Referent types

accessing members of, 871

definition, 864

Reflection

accessing metadata, 894895

accessing using System.Type class, 685

CIL (Common Intermediate Language), 894895

definition, 684

GetProperties() method, 685686

getting an object’s public properties, 685686

GetType() method, 685686

invoking, with dynamic, 719720

invoking with dynamic, 719720

member invocation, 687692

retrieving Type objects, 686687

support for extension methods, 723

TryParse() method, 690692

typeof() method, 686687

uses for, 684

Reflection, on generic types

classes, identifying support for generics, 692693

determining parameter types, 692

methods, identifying support for generics, 692693

type parameters for generic classes or methods, 693694

typeof operator, 692

__ reftype keyword, 8

__ refvalue keyword, 8

#region preprocessor directive, 153, 158159

Registering for

notification of task behavior, 760761

unhandled exceptions, 766768

Relational operators, 119120

ReleaseHandle() method, 858

Remove() method

event internals, 568

removing delegates from chains, 552

removing dictionary elements, 656

System.Delegate, 649

System.Text.StringBuilder, 58

RemoveAt() method, 649

Remove_OnTemperatureChange() method, 567568

Removing

delegates from a chain, 550552

dictionary elements, 656

elements from collections, 649

Replace, 58

ReRegisterFinalize() method, 429

Reserved keywords, 6, 8, 679680

Reset events, 836839

Reset() method, 584

Resource cleanup. See also Garbage collection.

class collections, 587

exception propagation from constructors, 428

finalization, 421427

finalization queue, 426

garbage collection, 426427

guidelines, 428

with IDisposable, 424425, 426427

introduction, 421

invoking the using statement, 425426

resurrecting objects, 429

Result property, 754

Results, 90

Resurrecting objects, 429

Rethrowing

existing exceptions, 438439

wrapped exceptions, 449453

Retrieving

attributes, 700702

member names, 729

Type objects, reflection, 686687

Return attributes, 698699

return statement, 173

Return values

calling methods, 163

from iterators, 669671, 673674

from Main() method, 180183

methods, 168169

from the ReadLine() method, 18

Reverse() method, 8586, 618

Reversing

arrays, 8182

strings, 8486

Right outer join, definition, 604

Right-associative operators, 93

Root references, 418

Round-trip formatting, 4445

Run() method, 772773

RunContinuationAsynchronously enum, 759

Running applications, 3

RunProcessAsync() method, 788789

Runtime. See also VES (Virtual Execution System).

circumnavigation encapsulation and access modifiers, 885

CLR (Common Language Runtime), 896

code access security, 886

definition, 26, 27

garbage collection, 883885

managed code, definition, 883

managed data, definition, 883

managed execution, definition, 883

performance, 887888

platform portability, 886887

reflection, 885

type checking, 885

type safety, 885

RuntimeBinderException, 722

S

SafeHandle, 857858

Save() method, 231232

sbyte type, 36

Scope

calling methods, 167

flow control statements, 116118

Sealed classes, 301302

sealed modifier, 311312

Sealed types constraint limitations, 484

Sealing virtual members, 311312

Search element not found, 651652

Searching

arrays, 8183, 651652

collections, 651653

lists, 651652

select clause, 623624

Select() method

projecting class collection data, 592594

vs. SelectMany(), 615616

SelectMany() method

calling, 614616

creating outer joins, 613616

vs. Select(), 615616

Semaphore, 839840

SemaphoreSlim, 839840

SemaphoreSlim.WaitAsync() method, 840

Semicolon (;), ending statements, 67, 11

Send() method, 796

SendTaskAsync() method, 796

SequenceEquals() method, 618

Sequential invocation, multicast delegates, 552, 554

Serializable objects, 449

Serialization() method, 714

Serialization-related attributes, 713714

Serializing

business objects into a database. See Reflection.

documents, 716718

set keyword, 240

Set() method, 836837

SetName() method, 228234

SetResult() method, 789

Setter methods. See Getter/setter methods.

Shared Source CLI compiler, 880

Short circuiting, with the null-coalescing operator, 124125

short types, 36, 37

SignalAndWait() method, 835

Signature verification, 722

Simultaneous multithreading, definition, 734

Single backslash character (\), escape sequence, 46

Single inheritance, 299301, 343344

Single-line comments, 24

Single-threaded programs, definition, 734

Slash, equal (/=) binary/assignment operator, 399

Sleep() method, 744745

Smiley face, displaying, 4748

Sort() method, 649650

SortedDictionary<T>, 660661

SortedList<T>, 660661

Sorting

arrays, 8182, 8283

class collections, 601603. See also Standard query operators, sorting.

collections, 649651, 660661

lists, 649650

Sorting, collections. See also Standard query operators, sorting.

by file size, 633634

by key, 660661

with query expressions, 632633

by value, 660661

Specializing types, 221

SqlException() method, 448

Square brackets ([ ]), array declaration, 7274

Stack

allocating data on, 868869

definition, 353

unwinding, 182183

values, accessing, 661662

Stack, 461

Stack collections, 661662

Stackalloc data, 868

StackOverflowException, 210

Stack<T>, 500501, 661

Standard query operators

AsParallel(), 595

caching data, 600

Concat(), 618

counting elements with Count(), 595596

deferred execution, 597598, 600601

definition, 588

Distinct(), 618

filtering with Where(), 591592, 597598

guidelines, 596, 641

Intersect(), 618

OfType(), 618

projecting with Select(), 592594

queryable extensions, 619

race conditions, 595

Reverse(), 618

running LINQ queries in parallel, 594595

sample classes, 588591

sequence diagram, 599

SequenceEquals(), 618

sorting, 601603

System.Linq.Enumerable method calls, 616617

table of, 618

Union(), 618

Standard query operators, join operations

Cartesian products, 608

DefaultIfEmpty(), 613614

full outer join, 604

grouping results with GroupBy(), 610611

inner join, 604, 607610

introduction, 603604

left outer join, 604

many-to-many relationships, 604

normalized data, 607608

one-to-many relationships, 604

one-to-many relationships, with GroupJoin(), 611613

outer joins, with GroupJoin(), 613614

outer joins, with SelectMany(), 613616

right outer join, 604

Start() method, 305306, 762763

StartNew() method, 772773

State

iterators, 671673

sharing, class collections, 585

Statement delimiters, 1112

Statement lambdas, 517519

Statements

vs. method calls, 169

multiple, on the same line, 1112, 13

splitting across multiple lines, 11, 12

syntax, 1112

STAThreadAttribute, 846

Static

classes, 273275

compilation vs. programming with dynamic objects, 725726

constructors, 271272

fields, 267268. See also Instance fields; static keyword.

methods, 5152, 269271

properties, 273

static keyword, 266. See also Static, fields.

Status property, 754

Stop() method, 305306, 808

Storage

disk, 662

files, 232235

reclaiming. See Finalizers; Garbage collection.

Store() method, 232235

String interpolation, formatting with, 20

string keyword, 48, 826827

string() method, 48

String methods

instance methods, 51

static methods, 5152. See also using directive; using static directive.

string type, 48, 202203

string.Format method, 51

string.join statement, 801

Strings

“ “ (double quotes), coding string literals, 48

@ (at sign), coding verbatim strings, 48

$ (dollar sign), string interpolation, 48

$@ (dollar sign, at sign), string interpolation, 50

as arrays, 8486

changing, 5657

concatenation at compile time, C++ language, vs. C#, 50

concatenation at compile time, vs. C++, 50

determining length of, 5556

formatting, 54

having no value vs. empty, 59

immutability, 5657

interpolation, 5053

length, 5556

Length member, 5556

literals, 48

, newline character, 46, 48

read-only properties, 55

representing a binary display, 132

starting a new line, 46, 48

type for, 48

verbatim string literals, 49

void type, 5960

Strong references, garbage collection, 420421

struct keyword

vs. class, 677

constraints, 478479

declaring a struct, 356

StructLayoutAttribute, 854855

Structs

declaring, 356

default value for, 360361

definition, 356

finalizer support, 360

generic types, 466467

initializing, 357359

referential identity, 360

Structural equality, delegates, 526527

subscriber methods, 544545

Subtypes, 220

Sum() method, 618

Super types, 220

SuppressFinalize() method, 426

Surrogate pairs, 46

Swap() method, 186

Swapping array data elements, 79

switch statements

catching exceptions, 436

code example, 142146

fall-through, C++ vs. C#, 145

syntax, 110

Switching overhead, 737

Synchronization. See Thread synchronization.

Synchronization context, 793795

Synchronization types. See Thread synchronization, synchronization types.

Synchronized() method, 827

Synchronizing

code, boxing, 366368

local variables, 819820

multiple threads with Monitor class, 821

Synchronous delegates, 751

Synchronous high-latency operations, 775777

Syntax

class definition, 89

identifiers, 67

immutable strings, 17

keywords, 46, 8

methods, 911

statement delimiters, 1112

statements, 1112

type definition, 89

variables, 1317

System, 165

System.Action delegates, 524525

System.ApplicationException, 210, 435, 436

System.ArgumentException, 210, 433, 436

System.ArgumentNullException, 210

System.ArithmeticException, 210

System.Array, 484

System.Array.Reverse() method, 8586

System.ArrayTypeMismatchException, 210

System.Attribute, 699, 711

System.AttributeUsageAttribute, 706709

System.Collection.Generic.List<T>.FindAll() method, 652653

System.Collections, 165

System.Collections.Generic.IEnumerable<T>. See IEnumerable<T> interface.

System.Collections.Generics, 165

System.Collections.Generic.Stack<T>, 464, 584587

System.Collections.IEnumerable. See IEnumerable interface.

System.Collection.Stack.Pop() method, 456459

System.Collection.Stack.Push() method, 456459

System.ComponentModel.Win32Exception method, 855856, 862

System.Console.Clear() method, 154

System.Console.Read() method, 19

System.Console.ReadKey() method, 19

System.Console.ReadLine() method

calling, 163164

reading from the console, 1819

return values, 168

System.Console.Write() method

calling, 163164

return values, 168

starting a new line, 48, 55

writing to the console, 1921

System.Console.WriteLine() method

calling, 163164

outputting a blank line, 55

overriding ToString() method, 384385

return values, 168

round-trip formatting, 4445

starting a new line, 48, 55

writing to the console, 1921

System.Convert, 6970

System.Data, 165

System.Data.SqlClient.SqlException(), 448

System.Delegate

constraint limitations, 484

delegate internals, 513516

multicast delegate internals, 554

System.Delegate.Combine() method

combining delegates, 552

constraint limitations, 484

event internals, 568

System.Delegate.Remove() method

event internals, 568

removing delegates from chains, 552

removing list elements, 649

System.Diagnostics.ConditionalAttribute, 710711

System.Diagnostics.Processor, 851

System.Diagnostics.Trace.Write() method, 384

System.Drawing, 165

System.Dynamic.DynamicObject, 728

System.Dynamic.IDynamicMetaObject Provider interface, 726729

System.Enum, 484

System.Enum.IsDefined() method, 379

System.Enum.Parse() method, 376

System.Environment.CommandLine, 10

System.Environment.FailFast() method, 435, 436

System.Environment.Newline method, 55

System.EventArgs, 563565

System.EventHandler<T>, 566

System.Exception, 209210, 435, 436

System.ExecutionEngineException, 435

System.FormatException, 210

System.Func delegates, 524525

System.GC, 419

System.GC.SuppressFinalize() method, 426

System.IndexOutOfRangeException, 210

System.IntPtr, 852

System.InvalidCastException, 210

System.InvalidOperationException, 210, 438

System.IO, 165

System.IO.FileAttributes, 377

System.Lazy<T>, 430431

System.Linq, 165

System.Linq.Enumerable

aggregate functions, 618

Average() method, 618

Count() method, 618

GroupBy() method, grouping results, 610611

GroupJoin() method, 611613

Join() method, 607610

Max() method, 618

method calls, 616617

Min() method, 618

Select() method, 592594

Sum() method, 618

Where() method, 591592

System.MulticastDelegate, 484, 513516

System.NonSerializable, 714715

System.NotImplementedException, 210

System.Nullable<T>, 461

System.NullReferenceException, 210

System.Object, 320321

System.ObsoleteAttribute, 712

System.OutOfMemoryException, 435

System.Reflection.MethodInfo property, 513

System.Runtime.CompilerServices.CallSite<T>, 723724

System.Runtime.ExceptionServices.ExceptionDispatchInfo.Catch() method, 439

System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() method, 439440

System.Runtime.InteropServices.COMException, 435

System.Runtime.InteropServices.SafeHandle, 858

System.Runtime.InteropServices.SEHException, 435

System.Runtime.Serialization.ISerializable, 715716

System.Runtime.Serialization.OptionalFieldAttribute, 718

System.Runtime.Serialization.SerializationInfo, 715716

System.Runtime.Serialization.StreamingContext, 715716

System.Security.AccessControl.MutexSecurity objects, 834

System.SerializableAttribute, 713714, 718719

System.ServiceModel, 166

System.StackOverflowException, 210, 435

System.String.string method, 48

System.SystemException, 435, 436

System.Text, 165

System.Text.RegularExpressions, 165

System.Text.StringBuilder, 58, 477

System.Text.StringBuilder.Remove() method, 58

System.Threading, 165

System.Threading.AutoResetEventSlim, 836839

System.Threading.Interlocked

Add() method, 829

CompareExchange() method, 828829

CompareExchange<T> method, 829

Decrement() method, 829

Exchange<T> method, 829

Increment() method, 829

Read() method, 829

System.Threading.Interlocked methods, 828829

System.Threading.ManualResetEvent, 836839

System.Threading.ManualResetEventSlim, 836839

System.Threading.Monitor, 821

System.Threading.Monitor.Enter() method, 366, 821, 823, 825826

System.Threading.Monitor.Exit() method, 366, 823, 825826

System.Threading.Monitor.Pulse() method, 823

System.Threading.Mutex, 833835

System.Threading.Tasks, 165

System.Threading.Thread, 734. See also Multithreading, with System.Threading.Thread.

System.Threading.Timer, 846

System.Threading.WaitHandle, 835

System.Timers.Timer, 846

System.Type class, accessing metadata, 685

System.UnauthorizedAccessException, 449

System.ValueType, 361362

System.WeakReference, 420

System.Web, 165

System.Windows, 166

System.Windows.Forms, 166

System.Windows.Forms.Timer, 846

System.Windows.Threading.DispatcherTimer, 846

System.Xml, 166

T

TAP (Task-based Asynchronous Pattern). See Multithreading, task-based asynchronous pattern.

Target property, 513

Task Parallel Library (TPL). See TPL (Task Parallel Library).

Task schedulers, 750751, 793795

Task-based asynchronous pattern. See Multithreading, task-based asynchronous pattern.

Task-based Asynchronous Pattern (TAP). See Multithreading, task-based asynchronous pattern.

TaskCanceledException, 772

TaskCompletionSource.SetResult() method, 789

TaskCompletionSource<T> object, 788789

TaskContinuationOptions enums, 758759

Task.ContinueWith() method, 756, 793794, 798

TaskCreationOptions.LongRunning option, 773774

Task.Delay() method, 745, 845846

Task.Factory.StartNew() method, 772773

Task.Run() method, 772773

Tasks

antecedent, 757

associating data with, 755

asynchronous. See Multithreading, asynchronous tasks.

canceling. See Multithreading, canceling tasks.

chaining, 757

cold, 752

composing large from smaller, 756758

continuation, 755762

control flow within, 784786

creating, 750751

definition, 735, 750

vs. delegates, 751

disposable, canceling, 774

drawbacks, 775

hot, 752

identification, 755

long-running, canceling, 773774

registering for notification of behavior, 760761

status, getting, 754

TaskScheduler, 793

Task<T>, 753754

Temporary storage pool. See Stack.

Ternary operators, definition, 123

TextNumberParser.Parse() method, 434

TextToUpper() method, 57

ThenBy() method, 601603

ThenByDescending() method, 602

Thermostat, 545546

this keyword

avoiding ambiguity, 229232

definition, 228

identifying field owner, 228229

locking, 826827

with a method, 230231

passing in a method call, 231232

in static methods, 270271

Thread management, 743744

Thread pool, definition, 735

Thread pooling, definition, 747749

Thread safe code, definition, 734

Thread safe delegate invocation, 550

Thread safety

definition, 819

delegates, 550

Thread synchronization. See also Deadlocks; Race conditions.

best practices, 831833

monitors, 821823

multiple threads, 821823

with no await operator, 820

timers, 845846

Thread synchronization, synchronization types

concurrent collection classes, 840841

reset events, 836839

Thread synchronization, thread local storage

definition, 841

ThreadLocal<T>, 841842

ThreadStaticAttribute, 843845

Thread synchronization, uses for

atomicity of reading and writing to variables, 819

declaring fields as volatile, 828

event notification with multiple threads, 830

lock keyword, 823825

lock objects, 825

lock performance, 825

lock synchronization, 823825

locking guidelines, 827

locking on this, typeof, and string, 826827

with MethodImplAttribute, 827

with MethodImplOptions.Synchronized() method, 827

multiple threads and local variables, 819820

sample pseudocode execution, 818

synchronizing local variables, 819820

synchronizing multiple threads with Monitor class, 821

with System.Threading.Interlocked methods, 828829

thread safety, definition, 819

thread-safe event notification, 831

torn read, definition, 819

unsynchronized local variables, 820

unsynchronized state, 817

volatile keyword, 828

ThreadAbortException, 745746

Threading model, definition, 734

ThreadLocal<T>, 841842

Threads

aborting, 745746

checking for life, 744

creating, 750751

definition, 734

foreground vs. background, 743

putting to sleep, 744

reprioritizing, 743

unhandled exceptions, 765768

waiting for, 743

Thread-safe event notification, 831

Thread.Sleep() method, putting threads to sleep, 744

ThreadState property, 744

ThreadStaticAttribute, 843845

Three-dimensional arrays, 7778

Throw() method, 439440

throw statements, 212215

ThrowIfCancellationRequested() method, 772

Throwing exceptions. See also Catching exceptions; Exception handling.

ArgumentNullException, 436

ArgumentOutOfRangeException, 436

checked and unchecked conversions, 451453

code sample, 434

description, 203204

guidelines, 450

identifying the parameter name, 435

nameof operator, 435, 436

NullReferenceException, 436

rethrowing, 438440

rethrowing wrapped exceptions, 449453

throw statement, 212215

without replacing stack information, 439

TicTacToe game. See also Arrays.

checking player input, 142143

conditional operators, 123

determining remaining moves, 141

#endregion preprocessor directive, example, 158159

escaping out of, 146147

if/else example, 111

initializing, 73

nested if statements, 112

#region preprocessor directive, example, 158159

source code, 901905

tracking player moves, 147148

Tilde (~) bitwise complement operator, 134

Time slice, definition, 736

Time slicing, definition, 736

Time slicing costs, 737

Timers. See Thread synchronization, timers.

TKey parameter, 479

ToArray() method, 600

ToCharArray() method, 8586

ToDictionary() method, 600

ToList() method, 600

ToLookup() method, 600

Torn read, definition, 819

ToString() method, 6970, 384385, 709

TPL (Task Parallel Library). See also Multithreading, parallel loop iterations.

asynchronous high-latency operations, 777781

performance tuning, 802803

Trapping errors, 203209. See also Exception handling.

TrimToSize() method, 662

True/false evaluation. See Boolean expressions.

Try blocks, 205206

TryGetMember() method, 728

TryGetPhoneButton() method, 186188

TryParse() method, 7071, 215216, 690692

TryParse<T>() method, 376

TrySetMember() method, 728

Tuple, 471472

Tuple.Create() method, 471472

TValue parameter, 479

Two-dimensional arrays, 74, 79

Type

array defaults, 73

compatibility, enums, 374375

conversion, programming with dynamic objects, 721722

incompatibilities, anonymous types, 576577

inference, generic methods, 487489

name qualifier, calling methods, 166167

Type categories, reference types

definition, 61

description, 6264

heaps, 6263

memory area of the referenced data, 63

Type categories, value types

? (question mark), nullable modifier, 6465

assigning to null, 6465

definition, 61

description, 62

Type definition

casing, 8

naming conventions, 8

overloading, 471472

syntax, 89

Type objects, retrieving, 686687

Type parameter list, declaring methods, 172

Type parameters

constraints on. See Constraints on type parameters.

generic classes, 464

for generic classes or methods, 693694

naming guidelines, 465466

Type parameters, 472, 489

Type safety

anonymous types, 576577

covariance, 498

managed execution, 27

programming with dynamic objects, 720721, 726

Type.ContainsGenericParameters property, 693

typeof keyword, locking, 826827

typeof() method, 686687

typeof operator, 520, 692

Types

aliasing, 179180. See also using directive.

anonymous, 61, 263265

bool (Boolean), 45

char (character), 14, 45

data conversion with the as operator, 322323

declaring on the fly. See Anonymous types.

definition, 15

encapsulating, 407408

extending. See Inheritance.

implicitly typed local variables, 6061

integral, 96

null, 5859

predefined, 3536

string, 48

for strings, 48

underlying, determining, 321322

Unicode standard, 4648

void, 58, 5960

well formed. See Well-formed types.

Types, conversions between

cast operator, 6566

casting, 65

checked block example, 67

checked conversions, 6668

defining custom conversions, 295296

explicit cast, 6566

implicit conversion, 65, 6869

numeric to Boolean, 68

overflowing an integer value, 6668

Parse() method, 6970

System.Convert class, 6970

ToString() method, 6970

TryParse() method, 7071

unchecked block example, 6768

unchecked conversions, 6668

without casting, 6970

Types, fundamental numeric. See also Literal values.

byte, 36

C# vs. C++ short type, 37

defaults, 4042

floating-point types. See Floating-point types.

formatting numbers as hexadecimal, 43

hardcoding values, 4042

hexadecimal notation, 4243

int, 36

int (integer), 14

integer literals, determining type of, 4142

integers, 3637

keywords associated with, 36

long, 36

sbyte, 36

short, 36

uint, 36

ulong, 36

ushort, 36

U

uint type, 36

ulong type, 36

UML (Unified Modeling Language), 345

Unary operators

definition, 122

overloading, 400401

UnaryExpression, 535

UnauthorizedAccessException, 449, 804

Unboxing, 363364, 366

Unchecked block example, 6768

Unchecked conversions, 6668

Uncompress() method, 326327

#undef preprocessor directive, 153, 155

Underscore (_)

in identifier names, 7

line continuation character, 11

in variable names, 15

Underscores (__), in keyword names, 8

Undo, with a generic Stack, 461

Undo() method, 458

Unexpected inequality, float type, 97100

Unhandled exceptions

error messages, 203204

handling with AggregateException, 762765

observing, 764765

registering for, 766768

on a thread, 765768

UnhandledException event, 766

Unicode standard, 4648

Unified Modeling Language (UML), 345

Union() method, 618

Unmanaged code, definition, 26

Unmanaged types, 865

Unmodifiable. See Immutable.

Unsafe code. See also P/Invoke; Pointers and addresses; WinRT.

description, 862864

executing by delegate, 872873. See also P/Invoke; WinRT.

unsafe code blocks, 863864

unsafe modifier, 863

unsafe statement, 863

/unsafe switch, 864

Unsynchronized local variables, 820

Unsynchronized state, 817

Unwrap() method, 779

ushort type, 36

using directives

dropping namespaces, 5354, 175177

example, 5354, 175

importing types from namespaces, 175177

nested namespaces, 176

nesting, 177178

wildcards, Java vs. C#, 176

using statement

deterministic finalization, 423426

resource cleanup, 425426

using static directive

abbreviating a type name, 178179

dropping namespaces, 5354

example, 5354, 178179

V

Validating properties, 244246

Value, passing parameters by, 183184

value keyword, 240

Value type conversion

to an implemented interface. See Boxing.

to its root base class. See Boxing.

Value types

custom types. See Enums; Structs.

default operator, 360361

guidelines, 353, 362

immutability, 357

inheritance, 361362

interfaces, 361362

introduction, 352353

new operator, 359360

vs. reference types, 184185, 353355

temporary storage pool. See stack.

Values

CTS types, 892

hardcoding, 4042

var keyword

anonymous types, 572576

C++ vs. C#, 575

implicitly typed local variables, 6061

JavaScript vs. C#, 575

Visual Basic vs. C#, 575

Variables. See also Local variables.

setting to null, 58

syntax, 1317

type, 14

using, 17

Variables, global, C++ vs. C#, 266

Variant

C++ vs. C#, 575

JavaScript vs. C#, 575

Visual Basic vs. C#, 575

VerifyCredentials() method, 344

Versioning, 716718

Versioning interfaces, 346347

Vertical bar, equal sign (|=) compound assignment operator, 133134

Vertical bar (|) OR operator, 131, 132, 397399

Vertical bars (||) OR operator, 121

VES (Virtual Execution System). See also CIL (Common Intermediate Language); CLI (Common Language Infrastructure); Runtime.

definition, 878, 896

managed execution, 26

Virtual abstract members, 317

Virtual computer, 872873

Virtual Execution System (VES). See VES (Virtual Execution System).

Virtual fields, properties as, 249250

Virtual functions, pure, 317

Virtual members, sealing, 311312

Virtual memory, allocating with P/Invoke, 852

Virtual methods

custom dynamic objects, 728

Java vs. C#, 440

overriding base classes, 302307

virtual modifier, 302307

VirtualAllocEx() API, 851853

VirtualMemoryManager, 851

VirtualMemoryPtr, 858

Visual Basic vs. C#

importing namespaces, 176

line-based statements, 11

this keyword, 230

var keyword, 575

Variant, 575

void*, 575

void type, 59

Visual code editors, 158159

void*

C++ vs. C#, 575

JavaScript vs. C#, 575

Visual Basic vs. C#, 575

Void methods, 173174

void type

C++ vs. C#, 59

description, 5960

no value vs. empty string, 59

in partial methods, 287

as a return, 173174

strings, 5960

use for, 58

volatile keyword, 828

W

Wait() method, 836837

WaitAll() method, 835

WaitAny() method, 835

WaitAsync() method, 840

WaitForExit() method, 788

WaitHandle, 774

WaitOne() method, 835, 837

Warning messages, disabling/restoring, 156157

#warning preprocessor directive, 153, 155156

Weak references, garbage collection, 420421

WebRequest.GetResponseAsync() method, 779

Well-formed types

determining whether two objects are equal, 392395

implementing Equals() equality operator, 392395

lazy initialization, 429431

object identity vs. equal object values, 388392

overriding Equals() equality operator, 392395

Well-formed types, garbage collection. See also Resource cleanup.

Collect() method, 419

introduction, 418

in .NET, 418419

root references, 418

strong references, 420421

weak references, 420421

Well-formed types, namespaces

in the CLR (Common Language Runtime), 410

extern alias directive, 413

guidelines, 412

introduction, 409410

namespaces alias qualifier, 412413

naming conventions, 410

nesting, 411

Well-formed types, overloading object members

Equals() equality operator, 388395

GetHashCode() method, 385387

ToString() method, 384385

Well-formed types, overloading operators

binary operators, 397399

binary operators combined with assignment operators, 397399

cast operator, 402

conditional logical operators, 400

conversion operators, 401, 403

unary operators, 400401

Well-formed types, referencing other assemblies

changing the assembly target, 404

class libraries, 404405

console executables, 404

encapsulation of types, 407408

internal access modifiers on type declarations, 407408

modules, 405

PCLs (portable class libraries), 406

protected internal type modifier, 408

public access modifiers on type declarations, 407408

referencing assemblies, 405406

referencing assemblies on Mac and Linux, 406

type member accessibility modifiers, 409. See also specific modifiers.

Windows executables, 405

Well-formed types, resource cleanup

exception propagation from constructors, 428

finalization, 421427

finalization queue, 426

garbage collection, 426427

guidelines, 428

with IDisposable, 424425, 426427

introduction, 421

invoking the using statement, 425426

resurrecting objects, 429

Well-formed types, XML comments

associating with programming constructs, 414416

generating an XML documentation file, 416418

guidelines, 418

introduction, 413414

when clauses, catching exceptions, 438

where clauses, 623624, 631632

Where() method, 591592, 597598

while loops, 108, 134135, 136137

While() method, 584

while statement, 108, 134135, 136137

Whitespace, 12, 13

Win32, error handling in P/Invoke, 855857

Windows Desktop CLR compiler, 880

Windows Runtime. See WinRT.

WinRT. See also P/Invoke.

automatically shimmed interfaces, 875876

definition, 896

description, 873874

task-based asynchrony, 876

WinRT events, 874875

Work stealing, 802803

Wrappers for API calls from P/Invoke, 860861

Write() method

starting a new line, 48, 55

writing to the console, 1921

WriteLine() method

round-trip formatting, 4445

starting a new line, 48, 55

writing to the console, 1921

Write-only properties, 247248

WriteWebRequestSizeAsync() method, 780, 783

X

XML (Extensible Markup Language), 25, 416418

XML comments

associating with programming constructs, 414416

delimited comments, 24

generating an XML documentation file, 416418

guidelines, 418

introduction, 413414

single-line, 24

Y

yield break statement, 677678

yield keyword, 6

yield return statement

in foreach loops, 674676

implementing BinaryTree<T>, 673676

requirements, 681

returning iterator values, 670671

yield return statements, 6

Z

ZipCompression, 337

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

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