By Joseph Albahari, Ben Albahari
Price: $49.99 USD
£30.99 GBP
Cover | Table of Contents | Forum
[ Symbols ], [ Numbers ], [ A ], [ B ], [ C ], [ D ], [ E ], [ F ], [ G ], [ H ], [ I ], [ J ], [ K ], [ L ], [ M ], [ N ], [ O ], [ P ], [ Q ], [ R ], [ S ], [ T ], [ U ], [ V ], [ W ], [ X ], [ Y ], [ Z ], Chapter 3 3
Symbols[ Top ]
< > (angle brackets)
> (greater than) operator, 28, 45
order comparisons, 224
overloading, 141
use with enums, 94
use with nullable types, 137
< (less than) operator, 28, 45
order comparisons, 224
overloading, 141
use with enums, 94
use with nullable types, 137
{ } (curly braces)
changing flow of execution in if-else statements, 48
regular expression metacharacter ({), 759
regular expression quantifier, 761
( ) (parentheses)
cast operator, 44
function call operator, 44
grouping operator, 44
regular expression metacharacters, 759
" " (quotes, double)
escape sqeuence, 29
in verbatim string literals, 30
specifying string literals, 30
' ' (quotes, single)
specifying char literals, 29
[ ] (square brackets)
array/index operator, 31, 44
enclosing attribute names, 147
multiple attributes, specifying, 148
regular expression metacharacter, 759
XPath, filter operator, 416
? : (ternary conditional) operator, 29, 45
true and false operators, using with, 142
+= (add to self) operator, 45
combining delegate instances, 106
event accessor implementation, 116
indirectly overloading, 140
use with enums, 94
& (ampersand)
address of value operator (unsafe), 45, 150
bitwise And operator, 25
operating on combined enum values, 93
use with nullable types, 137
logical And operator, 45
use with bool? type operands, 137
use with nullable types, 137
&= (And self by) operator, 45
* (asterisk)
multiplication operator, 23, 45
use with nullable types, 137
regular expression metacharcter, 759
* (asterisk) (continued)
regular expression quantifier, 760
value at address operator (unsafe), 44, 150
XPath, wildcard operator, 415
@ (at sign)
prefix for identifiers that clash with keywords, 12
prefixing verbatim string literals, 30
XPath, attribute operator, 415
\ (backslash)
escaping characters, 29
escaping strings, 29
regular expression metacharacter, 759
regular expressions, character escapes, 759
` (backtick), in generic type names, 565
///, beginning XML comments, 153
<< (bitwise shift left) operator, 25
>> (bitwise shift right) operator, 25
^ (caret)
bitwise exclusive Or operator, 25
operating on combined enum values, 93
use with nullable types, 137
logical Xor (exclusive Or) operator, 45
use with nullable types, 137
regular expression metacharacter, 759
regular expressions, beginning-of-string matching, 762
: (colon)
XPath, namespace separator, 416
&& (conditional And) operator, 28, 45
implicitly overriding, 140
|| (conditional Or) operator, 28, 45
implicitly overriding, 140
-- (decrement) operator, 24
post-decrement operator, 44
use with enums, 94
use with nullable types, 137
/= (divide self by) operator, 45
indirectly overloading, 140
$ (dollar sign)
regular expression metacharacter, 759
regular expressions, end-of-string matching, 762
- (em dash), 449
== (equals) operator, 12, 28, 45
comparing NaN values, 26
differences from Equals method, 219
overloading, 141, 221
standard equality comparisons, 216
string comparisons, ordinal case-sensitive, 176
use with enums, 94
use with nullable types, 137
= (equals sign)
assignment operator, 12, 43, 45
overloading, 141
use with enums, 94
! (exclamation mark)
not operator, 28, 44
use with nullable types, 137
^= (exclusive-Or self by) operator, 45
>= (greater than or equal to) operator, 28, 45
overloading, 141
use with enums, 94
use with nullable types, 137
# (hash mark)
conditional attributes, 152
preprocessor directives, 151, 738
regular expression metacharacter, 759
//, in comments, 8
++ (increment) operator, 24
post-increment operator, 44
pre-increment operator, 44
use with enums, 94
use with nullable types, 137
=> (lambda) operator, 45
<= (less than or equal to) operator, 28, 45
overloading, 141
use with enums, 94
use with nullable types, 137
- (minus sign)
negative value of operator, 44
use with nullable types, 137
subtraction operator, 23, 45
use with enums, 94
use with nullable types, 137
using with time spans, 182
*= (multiply self by) operator, 45
!= (not equals) operator, 28, 45
overloading, 141, 221
standard equality comparisons, 216
use with enums, 94
use with nullable types, 137
?? (null coalescing) operator, 138, 377
|= (Or self by) operator, 45
.. (parent node) operator, 415
% (percent sign), remainder operator, 23, 45
use with nullable types, 137
. (period)
member access operator, 44
regular expression metacharacter, 759
+ (plus sign)
addition operator, 23, 45
use with enums, 94
use with nullable types, 137
using with time spans, 182
positive value of operator, 44, 137
regular expression metacharacter, 759
regular expression quantifier, 761
string concatenation operator, 30
-> (pointer-to-member) operator, 150
-> (printer to struct) operator (unsafe), 44
? (question mark)
in nullable types, 135
regular expression metacharacter, 759
regular expression quantifier, 756
<< (shift left) operator, 45
use with nullable types, 137
>> (shift right) operator, 45
use with nullable types, 137
<<= (shift self left by) operator, 45
>>= (shift self right by) operator, 45
/ (slash)
division operator, 23, 45
use with nullable types, 137
XPath, child operator, 415
-= (subtract from self) operator, 45
event accessor implementation, 116
use with enums, 94
using with delegate operands, 107
~ (tilde)
bitwise complement operator, 25, 44
use with enums, 94
logical complement operator, use with nullable types, 137
prefixing finalizers, 71
:: token for namespace alias qualification, 59
| (vertical bar)
bitwise Or operator, 25
operating on combined enum values, 93
use with nullable types, 137
logical Or operator, 45
use with bool? type operands, 137
use with nullable types, 137
regular expression metacharacter, 759
regular expressions, alternation, 757
// XPath operator, querying all child nodes, 415
Numbers[ Top ]
\0 (nulls, escape sequence), 29
8- and 16-bit integral types, 25
A[ Top ]
\a (alert) escape sequence, 29
Abort method, Thread class, 683
Interrrupt method vs., 683
safe cancellation, 684
absolute filenames, 438
absolute URIs, 551
abstract classes and abstract members, 76
interface members, 87
abstract modifier, 775
events, 117
access modifiers, 85
examples of use, 86
restrictions on, 86
accessibility
capping, 86
virtual and overridden methods, 76
accessors, event, 116
ACLs (Access Control Lists), 624
acronyms, networking, 470
Action delegates, 242
Action delegates, 119
Activator class, CreateInstance method, 566
add and remove keywords, 117
AddAfterSelf (LINQ to XML), 375
AddBeforeSelf method (LINQ to XML), 375
addresses, network, 471
converting between IP addresses and domain names with DNS, 491
IPAddress class, 471
administrative elevation, 624
application manifest request, 625
administrative elevation, requesting, 537
ADO.NET, 167
AES (Advanced Encryption Standard), 630
Aggregate query operator, 359
aggregation methods, 357-359
aggregation query operators, 282
aliasing
namespace alias qualifiers, 58
types and namespaces, 57
AllowPartiallyTrustedCallers attribute, 622
AmbiguousMatchException, 573
Ancestors methods (LINQ to XML), 372
anchors (regular expression), 762
anonymous methods, 121
searching an array, 244
anonymous pipes, 441, 444
AnonymousPipeClientStream class, 444
AnonymousPipeServerStream class, 444
coordinating sending/receiving between client and server, 445
anonymous types, 146, 299
Any query operator, 360
anynchronous methods, 698-708
AppDomain class
CreateDomain method, 623, 710
DoCallBack method, 714
UnloadDomain method, 710
AppDomainSetup class, 711
application base directory, 439
application domains, 709-721
architecture, 709
creating and destroying, 710
DoCallback method, using, 714
multiple, using, 712
sharing data between, 716
intra-process remoting, 717-718
isolating types and assemblies, 718-721
threads and, 714
Application event log, 748
application layer (networks), 469
application manifest, 535, 537
deploying, 537
application servers, thread safety in, 662
ApplicationBase property, AppDomainSetup class, 711
ApplicationData folder, 459
ArgumentException class, 128
ArgumentNullException class, 128
ArgumentOutOfRangeException class, 128
arguments, 37
function, implications of definite assignment, 36
passing by value, 38
arithmetic operators, 45
use with enums, 94
Array class, 31, 239-247
AsReadOnly method, 247
Clear method, 242
Clone method, 240, 247
ConstrainedCopy method, 247
ConvertAll method, 247
Copy and CopyTo methods, 246
CreateInstance method, 241
ForEach method, 242
GetLength method, 32
GetValue and SetValue methods, 241
indexers, 240
IndexOf method, 139
querying length and rank, 243
Resize method, 239, 247
Reverse method, 246
searching, 243
Exists method, 244
FindAll method, 244
IndexOf and LastIndexOf methods, 244
TrueForAll method, 244
sorting methods, 245
order comparison, 245
WriteFirstValue method, 241
array elements
automatic initialization, 36
variables as, 35
array initialization expressions, 31
simplified, 33
ArrayList class, 248, 249
arrays, 31-35
bounds checking, 34
copying queue elements to, 252
default element initialization, 31
dynamic instantiation based on element type, 567
generic types vs., 102
length of, 31
multidimensional, 32
jagged arrays, 33
rectangular arrays, 32
obtaining array types, 563
params argument supplied as, 41
pointers to
within a fixed statement, 149
fixed-size buffers, 150
stackalloc keyword, 150
simplified initialization expressions, 33
type names, 565
as operator, 45, 75
ASCII, 179, 449
AsEnumerable method, Enumerable class, 305
ASP.NET, 165
AsQueryable extension method, 301, 316
assemblies, 3, 713
application manifest, 537
Assembly class, 538
members, listed, 539
obtaining an Assembly object, 539
assembly manifest, 536
functionally significant data stored in, 536
informational data stored in, 536
specifying assembly attributes, 537
attaching attributes to, 148
contents, 535
defined, 10
deploying outside base folder, 557
emitting, 592
saving emitted assemblies, 593
GAC (Global Assembly Cache), 544-546
installing assemblies to GAC, 545
versioning and, 545
isolating, 718-721
modules, 538
multifile assemblies, 538
names, 542
AssemblyName class, 543
fully qualified, 543
namespace-to-assembly reference, 782-790
packing into single-file executable, 558
selective patching, 560
reflecting, 578
loading assembly into reflection-only context, 578
modules, 579
resolving and loading, 554-557
assembly resolution, 554
AssemblyResolve event, 555
loading assemblies, 555
resolution rules, assembly and type, 554
resources and satellite assemblies, 546
cultures and subcultures, 553
directly embedding resources, 547
.resources files, 548
.resx files, 549
satellite assemblies, 551-553
running in a sandbox, 619
optional permissions, 620
sandboxing another assembly, 620-623
security attributes, 620
sharing isolated store across all in an application, 464
signing, 540-542
delay signing, 541
how to sign, 540
unreferenced, 560
assembly isolation, 464
assembly manifest, 535
assembly qualified name
generic type parameters, 565
obtaining a type through, 563
AssemblyBuilder class, 592
alternative directory for saving emitted assembly, 593
Save method, 593
AssemblyInfo.cs file, 537
AssemblyName class
checking public key before loading assembly, 561
setting properties for emitted assembly, 593
AssemblyResolve event, 555
finding assemblies outside base folder, 557
AssemblyVersion attribute, 542
changing, 545
assertions, 622
assignment, 12
assignment expressions, 43
assignment operators
compound, 43
listed, 45
right-associativity, 44
[Association] attribute (LINQ to SQL), 310
associations (LINQ to SQL queries), 310
associativity, operator, 43
left-associative operators, 43
right-associative operators, 44
asymmetric encryption, 635
asynchronous delegates, 650
starting worker thread task via, 650
asynchronous events, 708
asynchronous I/O, operating system, 440
asynchronous methods
alternatives to, 707
fake asynchronous methods in Steam subclasses, 706
reasons for existence of, 698
signatures, 699
asynchronous delegates vs., 700
using (TCP sockets server example), 700-703
writing, 704-706
atomic operations, 129
Array.ConstrainedCopy method, 247
atomicity
Interlocked class and, 664
locking and, 657
Attribute class, 147, 580
attributes, 146
assembly-based security attributes, 620
AttributeUsage attribute
application to Serializable attribute, 581
binary serialization, 519-522
classes, 147
conditional, preprocessor directives and, 152
custom, 583
attaching to dynamic constructs, 600
Interop attribute reference, 734-737
LINQ to SQL classes, 307
named and positional parameters, 147
navigating in X-DOM, 373
reflection, 579-584
attribute basics, 579
AttributeUsage attribute, 581
defining your own attribute, 581
listing attributes on a specific type, 584
retrieving attributes at runtime, 583
retrieving in reflection-only context, 584
removing sequence of, in X-DOM, 375
specifying multiple for a single code element, 148
targets, 148
TypeAttributes enum, 592
updating in X-DOM, 374
XML elements, 363
reading, 402
writing, 405
Attributes method (LINQ to XML), 373
AttributeTargets enum, 581
authentication, 478
CredentialCache object, 479
forms-based, 485
PreAuthenticate property on WebRequest class, 479
AuthenticationManager class, 478
authority (URIs), 472
authorization, 612
identity and role-based, 612, 626
operating system security, 624-626
running in standard user account, 624
automatic properties, 67
AutoResetEvent class, 667
simulating with Wait and Pulse, 681
Wait and Pulse vs., 675
Average query operator, 358
B[ Top ]
\b (backspace), 29
\b (word boundary) regular expressions, assertion, 763
backend technologies, 167
background threads, 647
BackgroundWorker class, 686-690
cancellation support, adding, 687
disposal of, 425
minimum steps in using, 686
progress reporting support, adding, 687
RunWorkerCompleted event, 687
subclassing, 688
backing store streams, 433, 437
chaining
compression example, 462
closing, 436
backing stores, 432
base 64 encoding, converting, 208
base class generic constraint, 101
base classes
constructors, order of execution, 79
inheritance from, 74
specifying for partial classes, 72
base keyword, 79, 775
base types, 206
Basic Multilingual Plane (BMP), Unicode, 181
BeginInvoke and EndInvoke methods, 650
BeginInvoke and Invoke methods, 664
BeginReverseEcho and EndReverseEcho methods (example), 704-706
big-endian or little-endian order, 450
binary formatters
BinaryFormatter class, 518
two-way versioning robustness, 521
using with data contract serializers, 505
XML formatters vs., 501
binary search methods, arrays, 244
binary serialization, 519-525
with ISerializable, 522-525
subclassing serializable classes, 524
[NonSerialized] attribute, 519
[OnDeserializing] and [OnDeserialized] attributes, 519
[OnSerializing] and [OnSerialized] attributes, 520
[OptionalField] attribute and versioning, 521
binary serializer, 498, 500, 517-518
adding [Serializable] attribute to a type, 517
formatters, 517
shaping of output by formatters, 501
binary stream adapters, 450
BinaryReader and BinaryWriter classes, 450
encoding text messages between TCP client/server, 495
binding, dynamic, 573
reducing with use of delegates, 574
BindingFlags enum, 574
retrieving nonpublic members with, 575
BitArray class, 253
BitConverter class, 209, 445
bit-mapped attributes, 580
bitwise operators, 25
working with combined enum values, 93
blocked threads
forcibly releasing with Abort method, 683
forcibly releasing with Interrupt method, 682
blocking threads, 652
asynchronous methods and, 698
spinning vs., 653
BMP (Basic Multilingual Plane), Unicode, 181
bool? type operands, use with & and | operators, 137
bool types, 14, 27
conversions, 28
equality and comparison operators, 28
bounds-checking array indexing, 34
boxing and unboxing, 82
boxing forced by object.Equals method on value types, 218
copying semantics of, 82
interfaces and boxing, 91
nullable values, 136
branching execution
bool type, 14
in IL, 589
break statements, 51
broadcasters, 112
BufferedStream class, 445
asynchronous method pattern and, 707
buffers
fixed size, 150
size for a FileStream, 440
built-in types, 14
byte type, 25
C[ Top ]
C#
compiler, xiv
new features in Version 3.0, 4-7
platform support, 3
relationship with CLR, 3
<c> tag, XML, 156
C++ templates, C# generics vs., 103
Calendar object, use with DateTime, 185
callbacks, P/Invoke layer and, 726
cancellation (threads), 684
BackgroundWorker class, 687
capping accessibility, 86
capturing, outer variables, 120
CardSpace, 169
case-insensitive comparisons, strings, 176
cast operator, 44
Cast query operator, 353
casting, 74
as operator, using, 75
boxing and unboxing, 82
downcasting, 75
enums to and from underlying integral type, 94
in explicit type conversions, 16
explicit cast of nullable types, 136
to nullable types, use with Element and Attribute methods, 377
between numeric types, 207
object to any interface it implements, 87
struct to an interface, 91
upcasting, 75
value types, to and from object, 81
catch clause (try statements), 122
multiple catch clauses to specify specific exception types, 124
preventing program termination, 123
specifying type of exception to catch, 123
CDATA (XML file), 398
certificates, SSL, 486
Char class, 170
char keyword, 776
char literal escape sequences, use in strings, 30
char type, 29, 170
static methods for categorizing characters, 170
character encodings, 449
character sets, 179
in regular expressions, 759
characters, escape sequence, 29
/checked+ command-line switch, 25
checked keyword, 776
checked operator, 24, 44
child nodes
navigation in X-DOM, 369-372
updating, 374
circular dependencies, 603
class keyword, 776
classes, 1, 60
abstract, and abstract members, 76
attribute, 147
constants, 69
declaring, 60
defined, 10
equality comparisons, GetHashCode method, 221
equality customization and, 219
fields, 60
finalizers, 71
implementing interfaces, 87
indexers, 67
inheritance (see inheritance)
instance constructors, 62
interfaces vs., when to use, 91
marshaling, 724
methods, 61
object initializers, 64
partial classes and methods, 72
properties, 65
sealing, 78
static, 15, 71
static constructors, 70
this reference, 64
ClickOnce, applications deployed with, 625
Close method, 424
stream adapters, 451
Stream class, 436
closed generic types, 97
static data, uniqueness of, 103
typeof operator, using, 100
CLR (Common Language Runtime), 3
place in .NET Framework, 159
(see also garbage collection)
code
examples from this book, using, xvi
generating dynamically, 585-591
unsafe, 148
code access security, 618
code invariants, 742
code point (Unicode), 179
<code> tag, XML, 156
CodeAccessPermission class, 613
RevertAssert method, 623
subclasses, 616
CollectionDataContract attribute, 512
collections, 229-273
Array class, 239-247
construction and indexing, 241-242
enumeration, 242
length and rank, finding, 243
reversing elements, 246
searching, 243
sorting, 245
BitArray class, 253
customizable and proxies, 262-268
CollectionBase class, 264
Collection<T> class, 262-264
DictionaryBase class, 267
KeyedCollection<TKey,TItem>, 265-267
ReadOnlyCollection<T>, 267
dictionaries, 256-262
dictionary classes, listed, 256
IDictionary and IDictionary<TKey,-TValue>, 257
sorted dictionaries, 260
enumeration, 230-236
IDictionaryEnumerator interface, 236
IEnumerable and IEnumerator, 230
implementing interfaces, 232-235
thread safety and, 661
equality comparisons, 219
HashSet<T>, 254
ICollection and IList interfaces, 236-238
IList and IList<T>, 238
lists, 247-252
LinkedList<T> class, 250
List<T> and ArrayList, 248-250
namespaces, 229
plug-in equality and order, 268-273
IComparer and Comparer, 270
IEqualityComparer and EqualityComparer, 268
StringComparer, 272
queues, 252
serialization with data contract serializers, 511-513
customizing collection and element names, 512
subclassed collection elements, 512
serialization with XmlSerializer, 530-532
stacks, 253
[Column] attribute, 307
COM+ and MSMQ, 168
COM interoperability, online material covering, 164
combinable enums, 93
comments, 8, 13
XML, 398
XML documentation comments, 153-158
predefined XML tags, 155-157
type or member cross-references, 157
user-defined XML tags, 157
CommonApplicationData folder, 459
isolated storage vs., 463
Comparer<T> class, 271
CompareTo method
IComparable interfaces, 224
String class, 175, 177, 224
strings, 31
comparison operators, 28
strings and, 31
using with enums, 94
Comparison<T> delegate, 245
compilation, 10
conditional (see conditional compilation)
compile time, type safety enforced at, 2
compiled types (in assemblies), 535
compiler (csc.exe), 10
/delaysign+ switch, 542
/keyfile switch, 540
lifted operators, use with nullable types, 136
/warnaserror switch, 153
compilers, C# 3.0 or 2.0, xiv
composite format strings, 174, 197
StringBuilder.AppendFormat method, 178
composite value types, equality comparisons, 215
composition strategies (LINQ queries), 295-298
progressive query construction, 295
using into keyword, 296
wrapping queries, 297
compound assignment operators, 43
comprehension queries, 282-286
building progressively, 295
iteration variables, 284
lambda syntax vs. comprehension syntax, 285
mixed syntax queries, 285
SQL syntax vs. comprehension syntax, 284
Compressed and Encrypted file attributes, 454
compression, 461-463
binary file (example), 461
chaining compression and encryption streams, 634
compressing in memory, 462
DeflateStream and GZipStream classes, 461
text file (example), 462
Concat query operator, 282, 352
concatenating strings, 30
automatic XText concatenation, 378
String.Concat method, 174
concurrency, TCP server, 495
conditional compilation, 738-741
Conditional attribute, 740
static variable flags vs., 739
conditional operators
listed, 45
right-associativity, 44
short-circuiting evaluation, 29
conditional statements, using true and false operators, 142
Console class, 226
acceptance of composite format strings, 197
WriteLine method, 8
const keyword, 69, 776
constant expressions, example, 42
constants, 13, 69
declared local to a method, 70
differences from static readonly fields, 69
modifiers, 70
constraints on a generic parameter, 100
constructors, 9, 14, 62
base class, order of execution, 79
defined, 15
emitting, 599
calling base constructors, 599
field initialization order and, 63
implicit paramaterless, 63
inheritance and, 79
constructor and field initialization order, 80
implicit callof of parameterless base class constructor, 80
modifiers, 62
nonpublic, 63
overloading, 63
parameterless constructor constraint on generics, 101
retrieving metadata, 570
static, 70
struct, 85
containership hierarchy (X-DOM), 363
Contains query operator, 360
ContentLength property, WebResponse class, 490
contextual keywords, 12
continue keyword, 776
continue statements, 52
contravariance, 111
ControlAppDomain permission, 616
conversion operators (LINQ), 286
conversions, 16
BitConverter class, 209
bool types and, 28
char types, 30
enums, 212
numeric
floating-point to floating-point, 23
floating-point to integral, 23
integral to integral, 22
numeric, summary of, 209
query operators, 353-355
type converters, 208
XmlConvert class, 208
(see also Convert class; formatting and parsing)
Convert class, 206
base 64 conversions, 208
converting base types to every other base type, 206
dynamic conversions with ChangeType method, 207
parsing numbers in base 2, 8, and 16, 207
rounding real to integral conversions, 207
cookies, 484
forms authentication and, 485
Count query operator, 357
covariance, 111
generic types and, 102
CredentialCache object, 479
DefaultNetworkCredentials property, 479
Credentials property, WebClient or WebRequest class, 478
cross-platform code, writing in C#, 3
cross-references
<see> tag, XML, 156
<seealso> tag, XML, 156
XML type or member cross-references, 157
cryptographically strong random values, 632
cryptography, 627-638
encryption permissions, 617
hashing, 629
public key, encryption and signing, 635-638
digital signing, 637
RSA class, 636
summary of options in .NET, 627
support in .NET, 612
symmetric encryption, 630-635
chaining encryption streams, 633
encrypting in memory, 632
Windows Data Protection, 628
CryptoStream class, 631
asynchronous method pattern and, 707
chaining with other streams, 633
disposal of, 426, 634
CryptoStreamMode enum, 631
.cs files (source code), 10
csc.exe (see compiler)
culture codes, 553
culture-dependent comparison, strings, 224
CultureInfo class, 196, 553
format providers and, 196
cultures, 553
AssemblyCulture attribute, 543
culture-sensitive comparisons, strings
case-sensitive order comparison, 177
ordinal comparison vs., 176
CurrentCulture property, 553
CurrentUICulture property, 553
custom attributes, 580
attaching to dynamic constructs, 600
retrieving at runtime, 583
custom format strings, 199
numeric, 201
CustomAttributeData class, 584
D[ Top ]
data contract name, 504
data contract namespace, 504
data contract serializers, 498, 502-511
attaching attributes to make types serializable, 503
binary formatter, using, 505
DataContractSerializer, 502
extending, 513-517
binary interoperability, 515
interoperating with IXmlSerializable, 516
serialization and deserialization hooks, 514
instantiating and calling WriteObject or ReadObject, 503
NetDataContractSerializer, 502
null or empty values for data members, 510
object references, 507
preserving, 508
ordering of data members, 510
overriding names for data members, 504
overview, 500
purpose of, 499
data contract serializers (continued)
serializing collections, 511
customizing collection and element names, 512
subclassed collection elements, 512
serializing subclasses, 505
shaping of output by formatters, 501
steps in using, 502
version tolerance, 509
required data members, 509
XML formatter, 504
data members, 14
Data Protection API, 628
data slots
data sharing between application domains, 716
storage of thread data, 685
data structures, 31
DataContext class, 307
SubmitChanges method, 313
DataLoadOptions class, 312
advance specification of a filter for EntitySet associations, 312
eager loading of EntitySets, 313
DataProtectionScope enum, 629
dates and times, 181-188
time zones and, 188-194
TimeSpan, 181
DateTime and DateTimeOffset structs, 183
choosing between, 183
constructing a DateTime, 184
constructing a DateTimeOffset, 185
converting to and from UTC in TimeZoneInfo class, 191
current date and time, 186
DateTime and daylight saving, 193
DateTime and time zones, 188
DateTime, converting to and from byte array, 209
DateTime format strings, 203
DateTime formatted with invariant culture, 196
DateTime, Parse and ParseExact methods, 185
DateTimeOffset and time zones, 189
DateTimeOffset equality comparisons, 219
daylight saving time, working with in TimeZoneInfo, 191
formatting and parsing, 187
null values, 188
time zone conversions in TimeZoneInfo class, 191
working with dates and times, 186
DateTimeFormatInfo class, 196
using, 197
DateTimeStyles enum, 197, 205
daylight saving time
DateTime and, 193
TimeZone class, 190
TimeZoneInfo class, 190
transition time, 192
deadlocks, 657
deallocation of managed memory, 426
Debug and Trace classes, 741-744
Fail and Assert methods, 741
flushing and closing listeners, 743
Trace class, additional methods, 742
TraceListener, 742
Write, WriteLine, and WriteIf methods, 741
debugger integration, 744
attaching and breaking, 744
DebuggerHidden attribute, 744
DebuggerStepThrough attribute, 744
decimal keyword, 776
decimal literals, suffixes, 22
decimal notation, numeric literals, 21
decimal type, 21
conversions to and from other numeric types, 23
converting to and from int arrays, 209
double vs., 27
declaration statements, 46
declarations, XML, 363, 380
declarative security, 615
decorator sequences (LINQ), 288
chaining, 290
decorator streams, 433
chaining (compression example), 462
closing, 436
DeflateStream and GZipStream classes, 461
decrement operator (--), 24
deep-cloning
data contract serializer and, 506
X-DOM objects, 368
default keyword, 776
getting default value of a generic type argument, 100
DefaultIfEmpty query operator, 357
deferred execution, LINQ queries, 286-292
chaining decorators, 290
how deferred execution works, 288
how queries are executed, 291
interpreted queries, 302
LINQ to SQL, 311
outer variables, 287
reevaluation, 287
subqueries and, 294
#define directive, 738
definite assignment, 36
DeflateStream class, 461
asynchronous method pattern and, 707
closing and flushing with using statement, 462
decompressing referenced assemblies, 560
opt-in disposal, 426
delay signing (assemblies), 541
delegate keyword, 776
writing anonymous methods, 121
delegates, 105-112
Action<T>, 242
asynchronous, 650
boosting performance in dynamic method invocations, 574
choosing or defining for an event, 113
Comparison<T>, in array sorting, 245
compatibility
parameter compatibility, 111
return type, 111
type compatibility, 110
delegate instance, 105
delegate type, 105
dynamic method as typed delegate, 588
dynamically instantiating, 567
expression trees vs. in LINQ queries, 315-317
AsQueryable operator, 316
compiling expression trees, 316
generic lambda expressions and Func<T> delegates, 119
generic types, 108
instance method targets, 108
interfaces vs., 109
local LINQ queries, 300
mapping to unmanaged function pointers, 726
multicast, 106
example, 107
predicate-based searching methods, 244
writing plug-in methods, 106
Demand method, IPermission interface, 614
dependencies, circular, 603
deploying assemblies outside application base directory, 557
derived classes, 74
Descendants and DescendantNodes methods (XContainer), 371
deserialization, 498
(see also serialization)
destructors, 9
diagnostics, 738-755
conditional compilation, 738-741
Conditional attribute, 740
static variable flags vs., 739
Debug and Trace classes, 741-744
TraceListener, 742
debugger integration, 744
measuring execution times, 754
performance counters, 749-754
permissions, 617
processes and process threads, 745
StackTrace and StackFrame classes, 746
Windows event logs, 747-749
dictionaries, 256-262
caching requested assemblies in, 560
dictionary classes, listed, 256
Dictionary<TKey,TValue> and hashtable, 258
equality comparisons, 219
IDictionary interface, 257
IDictionaryEnumerator interface, 236
IDictionary<TKey,TValue> interface, 257
ListDictionary and HybridDictionary, 260
OrderedDictionary class, 260
serialization, controlling with CollectionDataContract, 513
sorted, 260
unsorted, comparers and, 270
dictionary attacks, 630
Dictionary class, hashing behavior, 268
dictionary entries, 236
DictionaryBase class, 267
DictionaryEntry structs, 258
digital signing (see signing, digital)
direct references to operating system resources, releasing, 429
directives
preprocessor, 151
#warning symbol, 152
Directory class, 456
disassembler, writing, 606-611
disposable objects, optional, 452
disposal, 422
DeflateStream class, 462
encryption objects, 634
standard semantics, 423
stream adapters, 451
when to dispose, 424
Dispose method
calling within finally block of try statement, 125
IDisposable interface, 422-426
calling from a finalizer, 428
calling, shortcut in using statement, 422
opt-in disposal pattern, 425
standard semantics, 423
Stream class, 436
Distinct query operator, 327
distributed system technologies, 168
DivideByZeroException, 123
division on integral types, 24
DivisionByZeroException, 24
.dll (library), 10
DllImport attribute, 734
DLLs, calling into, 722
DNS (Domain Name System), 470
Dns class, 491
documentation comments, XML, 153-158
predefined XML tags, 155-157
type or member cross-references, 157
user-defined XML tags, 157
documentation, XML, 13
documents, XML, 379-382
declarations, 381
XDocument class, 379
XPathDocument class, 417
(see also XmlDocument class)
DOM (Document Object Model)
defined, 362
LINQ to XML, 363
domain isolation, 464
DomainUnload event, 712
double keyword, 776
double type, 21
decimal vs., 27
real number rounding errors, 27
special values, 26
do-while loops, 50
downcasting, 74, 75
as operator, 75
testing with is operator, 75
DriveInfo class, 459
dynamic binding, 573
dynamic conversions with Convert class, 207
dynamic type checking, 82
dynamic type safety, 2
DynamicMethod class, 585
creating method (example), 585
E[ Top ]
Element method, 371
element operators, 355
element query operators, 281
ElementAt query operator, 356
ElementAtOrDefault query operator, 355
elements
LINQ, 274
XML, 363
order written by XmlSerializer, 527
reading with XmlReader, 399
Elements method (LINQ to XML), 370
#elif directive, 739
else clause, 47
#else directive, 739
elsif construct, 48
em dash (-) character, 449
emission targets, awkward, 602-605
circular dependencies, 603
uncreated closed generics, 602
empty elements, reading with XmlReader, 400
Empty query operatory, 360
empty strings, 172
empty values, data members, 510
encapsulation, 1
private class members by public members, 16
promotion by access modifiers, 85
Encoding class, 180, 449
controlling encoding for file and stream I/O, 180
GetBytes and GetString methods, 180
Encrypt and Decrypt methods, File class, 454
Encrypted file attribute, 454
encryption permissions, 617
end of a file, testing for, 448
EndInvoke and BeginInvoke methods, 650
entities, XML, 398
entity classes (LINQ to SQL), 307, 321
associations, 310
automatic generation, 309
EntityRef class, 311
EntitySet class, 310
eager loading, 313
specifying in advance a filter for associations, 312
EntryWritten event, 749
Enum class
IsDefined method, 95
ToString method, 95
Enumerable class, 275
AsEnumerable method, 305
extension methods, 283
enumeration, 130-135, 230-236
arrays, 242
IndexOf and LastIndexOf methods, 244
enumerable objects, 130
constructing, 134
enumerators, 130
IDictionaryEnumerator interface, 236
IEnumerable and IEnumerator interfaces, 230
implementing interfaces, 232-235
iterator semantics, 132
iterators, 131
composing sequences, 133
performance counters, 750
sorted list, keys and values, 261
thread safety and, 661
enumerations, collection
keyed collection, 265
enums, 92-95
CLR translation of, 571
conversions, 92, 212
enum to integral, 212
integral to enum, 213
to strings, 213
Enum class, 211
enumerating enum values, 213
flags enumerations, 93
format strings, 205
how they work, 214
retrieving member metadata, 570
type-safety issues, 94
using comparison operators, 28
Environment class, 227
GetFolderPath method, 459, 466
environment class
Process class, 228
equality comparisons, 12, 175, 215-223
== and Equals method, differences in, 219
customizing, 219
example, 222
overloading == and !=, 221
overriding equality semantics, 220
overriding Equals method, 221
overriding GetHashCode method, 220
pluggable equality comparers, 223
DateTime and DateTimeOffset, 183
dictionaries, 259
IEquatable<T> interface, 218
plug-in, 268-273
interfaces, 268
referential vs. value equality, 215
standard protocols for, 215
== and != operators, 216
virtual Equals method, Object class, 216
static Equals method, object class, 217
equality comparisons (continued)
static ReferenceEquals method, object class, 218
strings, 175, 176
equality operators, 28
listed, 45
overloading, 141
use with nullable types, 137
EqualityComparer class, 269
Equals method
EqualityComparer class, 269
Object class, 217
pluggable equality and order comparers, 268
errors
getting last Win32 error, 729
networking request/response model, 481
status code, 482
escape sequences, 29
evaluation stack, 586
event keyword, 112
event wait handles, 667-672
advantages over Wait and Pulse signaling, 673
creating and disposing wait handles, 669
creating cross-process EventWaitHandle, 671
pooling wait handles, 671
simulating with Wait and Pulse, 681
static methods on WaitHandle class, 672
two-way signaling, 669
EventArgs class, 113
EventHandler<> generic delegate, 114
EventInfo class, 572
EventLog class, 747
CreateEventSource method, 748
GetEventLogs method, 749
WriteEntry method, 748
EventLogEntryType enum, 748
events, 2, 9, 112-117
accessors, 116
asynchronous, 708
broadcaster, 112
choosing or defining a delegaate for, 113
FileSystemWatcher class, 460
metadata and backing methods, 571
identifying backing methods, 572
modifiers, 117
preventing subscribers from interfering with each other, 112
retrieving metadata, 570
standard event pattern, 113-116
subscribers, 112
EventWaitHandle class, 667
cross-process EventWaitHandle, 671
<example> tag, XML, 156
Except query operator, 352
Exception class, 123
key properties, 127
exception handling
ILGenerator methods for, 591
networking request/response model, 481
threads, 649
Exception object, 122
<exception> tag, XML, 155
exceptions
common patterns
alternatives to exceptions, 130
atomicity pattern, 129
try method pattern, 128
common types, 128
throwing, 126
rethrowing an exeption, 126
try statements and, 122-130
catch clause catching System.Exception, 123
multiple catch clauses to handle multiple exception types, 124
executable files
packing application into single-file executable, 559
selective patching, 560
ExecuteAssembly method, 560
Execution permission, 616
execution times, measuring, 754
exiting applications, threads and, 647
explicit casting, required for unboxing, 82
explicit conversions, 16
integral to integral conversions, 22
overloading, 140, 141
situations in which they're required, 17
explicit event accessors, defining, 116
explicit nullable conversions, 136
explicit serialization, 501
explicitly implemented interface members, overriding, 89
alternatives to reimplementation, 90
explicitly implementing an interface member, 88
Expression class, 317
methods, listed, 318
expression statements, 46
expression trees, 118, 300
delegates vs. in LINQ queries, 315-317
AsQueryable operator, 316
compiling expression trees, 316
interpreted query, 302
lambda expression, 317-319
expressions, 8, 42-45
assignment, 43
defined, 42
lambda, 118-121
operators
listing of C# operators, 44
operator precedence and associativity, 43
overflow checking, 25
primary, 42
void, 42
Expression<T> class, 118
Expression<TDelegate> class, 317
Extensible Stylesheet Language Transformations (see XSLT)
extension methods, 143-146
ambiguity and resolution
extension vs. extension methods, 145
extension vs. instance methods, 144
namespaces, 144
calling query operators in LINQ, 275
importance of, 278
chaining, 143
on interfaces, 145
extern keyword, 722, 777
extern namespaces, 57
F[ Top ]
\f (formfeed), 29
false and true literals, overloading, 140
FieldInfo class, 573
FieldOffset attribute, 735
fields, 60
automatic initialization at runtime, 36
declaring multiple fields together, 61
emitting, 597
initialization, 61
initialization order, constructors and, 63
modifiers, 61
readonly, 61
retrieving metadata, 570
variables as, 35
File class
CreateText, AppendText, and OpenText methods, 448
Encrypt method, 628
instantiating a FileStream, 438
FileAttribute enum, 453
FileDialogPermission class, 617
FileIOPermission class, 613
FileMode enum, 439
using in IsolatedStorageFileStream construction, 465
filenames, 438
loading assemblies from, 556
Path class, 457
FileOptions flags enum, 440
files and directories, 452-461
Directory class, 456
File class, 453-456
compression and encryption attributes, 454
file security, 455
FileAttribute enum, 453
methods, listed, 453
file paths, conversion to URIs, 473
FileInfo and DirectoryInfo classes, 456
FileSystemWatcher class, 460
isolated storage (see isolated storage)
Path class, 457
special folders, 459
static and instance method classes, 453
volume information, querying with DrivInfo class, 459
FileSecurity object, 440, 455
FileShare enum, 440
FileStream class, 437-440
advanced FileStream features, 440
built-in buffering, 445
FileStream class (continued)
constructing a FileStream, 438
fake asynchronous methods, 707
specifying a FileMode, 439
specifying a filename, 438
specifying permissions during file creation, 455
filesystem (isolated storage), 463-468
FileSystemWatcher class, 460
buffer size, changing, 461
IncludeSubdirectories, 461
filtering (query operators), 324-327
finalizers, 71, 427
calling Dispose from, 428
CLR translation of, 571
guidelines for implementing, 428
retrieving metadata, 570
finally block
try statements, 122, 125
atomic operations and, 129
using statement shortcut calling Dispose, 125
finally keyword, 777
First query operator, 356
FirstNode property (LINQ to XML), 370
FirstOrDefault query operator, 371
fixed keyword, 733
fixed statement, 149
fixed-size buffers, 150
flag enums, checking for validity, 95
Flags attribute, enumerations, 93
float type, 21
real number rounding errors, 27
special values, 26
floating-point numbers, 20
floating-point types, 21
conversion to integral numbers, 23
converting between, 23
Flush method
stream adapters, 451
Stream class, 437
folders, special (in Windows), 459
for keyword, 777
for loops, 50
iterating through array elements, 31
foreach keyword, 777
foreach statements, 51
enumerating arrays, 242
enumerator. calling, 231
iterating over enumerable objects, 130
foreground threads, 647
Format method, String class, 174
format providers, 195
format strings, 195
custom, 199
numeric format strings, 201
DateTime, 203
parsing and misparsing, 204
enum, 205
standard, 199
formatters
binary formatter and two-way versioning robustness, 521
binary serializer, 518
binary, using with data contract serializers, 505
shaping output of data contract and binary serializers, 501
XML formatter, use with data contract serializers, 504
formatting and parsing, 194-199
Enum.Format and Enum.Parse methods, 213
format providers, 195-199
composite formatting, 197
CultureInfo and, 196
ICustomFormatter and, 198
parsing with, 197
using NumberFormatInfo or DateTimeFormatInfo, 197
String.Format and composite format strings, 174
ToString and Parse, 195
forms
authentication based on, 485
uploading data, 483
from clause (comprehension queries), 283
FTP (File Transfer Protocol), 470, 489-491
commands defined as string constants in WebRequestMethods, 490
errors, 481
upload and download operations, 489
FtpWebResponse class, 491
fully qualified names, 54
assembly name, 543
referencing two types with same name, 57
Func delegates, 119
lambda expressions and, 280
function members, 2, 14
function pointers (in C), 726
functional construction (X-DOM), 367
functions, sealing, 78
G[ Top ]
GAC (Global Assembly Cache), 544-546
disadvantages of using, 544
installing assemblies to GAC, 545
versioning and, 544, 545
garbage collection, 422, 426-431
alternatives to, 430
suppressing garbage collection, 431
deallocation of objects from the heap, 35
finalizers and, 427
calling Dispose from a finalizer, 428
how the garbage collector (GC) works, 429
forcing collection, 430
optimization techniques, 429
remoting within the same process, 718
GC (garbage collector)
how it works, 429
forcing garbage collection, 430
optimization techniques, 429
tracing garbage collectors, 429
generation methods, 360
GenericIdentity class, 627
GenericParameterAttributes enum, 602
GenericPrincipal class, 627
generics, 96-104
C# vs. C++ templates, 103
collection classes, 262
constraints on generic parameters, 100
covariance and, 102
declaring generic parameters, 99
default generic value of a generic type argument, 100
emitting generic methods, 601
emitting generic types, 602
generic delegate types, 108
generic methods, 98
invoking, 576
requirement for classification as, 99
generic type names, 565
used by standard LINQ query operators, 280
generic types, 97
reflecting and activating, 567
member metadata for generic types, 572
reason for existence, 97
static data for a closed type, 103
subclassing generic types, 102
typeof operator, using, 100
uncreated closed generics, 602
GenericTypeParameterBuilder objects, 601
get and set accessors
access levels, 67
inlined by JIT compiler, 67
get keyword, 777
GetHashCode method
EqualityComparer class, 269
pluggable equality and order comparers, 268
get_Item and set_Item methods, 69
Global Assembly Cache (see GAC)
global namespace, 54
globally unique identifiers, Guid struct, 214
goto keyword, 777
goto statements, 52
greedy quantifiers, 761
group clause (comprehension queries), 283
GroupBy query operator, 349-352
GroupJoin query operator, 339
groups, regular expression matches, 764
Guid struct, 214
GZipStream class, 461
H[ Top ]
hash codes, 220
HashAlgorithm class, 629
hashing, 629
HashSet<T> class, 254
hashtables, 220
Dictionary<TKey,TValue> class, 258
Hashtable class, 268
headers, HTTP, 482
heap, 35
allocation within fixed block, avoiding, 149
hexadecimal notation, 21
hidden function members, accessing, 79
hiding interface members by type that implements it, 89
hiding names (in namespaces), 55
hierarchy, class, 73
HTTP (Hypertext Transfer Protocol), 470, 471
errors, 481
port 80, 472
request/response features, 482-486
cookies, 484
forms authentication, 485
headers, 482
query strings, 482
SSL, 486
uploading form data, 483
writing a server, 486-489
web page server (example), 488
HttpListener class, 486
https: protocol, 476
HybridDictionary class, 260
I[ Top ]
IAsyncResult interface, 650
ICollection interface, 236, 237
ICollection<T> interface, 236, 237
IComparable interface
comparison operator overloading and, 141
implementing, 225
sorting arrays, 244
IComparable<T> interface, 101, 223
comparison operator overloading and, 141
implementing, 225
sorting arrays, 244
IComparer and IComparer<T> interfaces, 268
definitions, 270
order comparisons of arrays, 244
ICryptoTransform interface, 707
ICustomFormatter interface, 198
IDbConnection class, Dispose method, 425
identifiers, 11
conflicts with keywords, avoiding, 12
identities, 626
IDictionary interface, 236, 257
implementation by DictionaryBase, 267
IDictionaryEnumerator interface, 236
IDictionary<TKey,TValue> interface, 236, 257
IDisposable interface
Dispose method, 125, 422-426
standard semantics, 423
IEEE 754 specification, format types, 26
IEnumerable interface, 130, 230
implementation by enumerable objects, 135
implementing, 232
IEnumerable<T> interface, 130, 232
implementation by LINQ sequences, 274
implementing, 232
IEnumerator interface, 87, 130, 230
implementing, 234
IEnumerator<T> interface, 130, 231
implementing, 235
IEqualityComparer interface, 223, 268
IEqualityComparer<T> interface, 268
IEquatable<T> interface, 218
implementing when overriding Equals, 222
#if directive, 738
if statements, 47
bool type used in branching execution, 14
if-else statement, 47
IFormatProvider interface, 196, 198
IFormattable interface, 195
IGrouping<,> interfce, 577
IIdentity interface, 627
IIS (Internet Information Services), 471
IL (Intermediate Language), 3
branching, 589
creating at runtime, 585
evaluation stack, 586
generating with DynamicMethod, 585
instantiating objects and calling instance methods, 589
parsing, 605-611
writing a disassembler, 606-611
ildasm tool, 586
ILGenerator class, 585
DeclareLocal method, 588
exception handling methods, 591
IList and IList<T> interfaces, 236, 238
imperative security, 615
implicit casting, 87
implicit conversions, 16
integral to integral conversions, 22
overloading, 140, 141
situations in which they're allowed, 16
implicit nullable conversions, 135
implicit serialization, 501
implicit typing
in arrays, 34
local variables, 41
In and Out marshaling, 725
<include> tag, XML, 157
increment operator (++), 24
indexers, 9, 67
array, 31, 240
bounds checking indexes, 34
multidimensional arrays, 241
CLR implementation, 69
CLR translation of, 571
emitting, 597
implementing, 68
modifiers, 68
multiple, declared by a type, 68
parameters, 69
retrieving metadata, 570
string, 172
IndexOutOfRangeException, 34
infinite loops, 51
infinite values, 26
infix notation, 279
inheritance, 73-81
abstract classes and abstract members, 76
base keyword, 79
casting and, 74
constructors and, 79
constructor and field initialization order, 80
implicit calling of parameterless base class constructor, 80
delegates, 107
hiding inherited members, 77
multiple, interfaces and, 1
overloading and resolution, 80
polymorhipsm, 74
sealing functions and classes, 78
virtual function members, 76
X-DOM hierarchy, 363
Initialization Vector (IV), 631
inlining, 67
InnerException property, 127
InnerText and InnerXml properties, XmlDocument, 412
input sequence (LINQ), 274
input/output (see streams and I/O)
instance members, 15
instance methods
calling in IL, 590
emitting, 597
extension methods vs., 144
instantiating a type, 15
instructions, IL, 607
int keyword, 778
int type, 13
boxing and unboxing, 82
favored integral type, 21
Parse method and TryParse method, 128
integral literals, 21
integral types, 21
8- and 16-bit, 25
arithmetic overflow check operators, 24
converting enums to, 212
converting floating-point numbers to, 23
converting to enums, 213
division, 24
overflow, 24
rounding in real to integral conversions, 207
underlying value of enum members, 92
integrating with native DLLs, 722-737
callbacks from unmanaged code, 726
calling into DLLs, 722
In and Out marshaling, 725
mapping a struct to unmanaged memory, 730-733
marshaling classes and structs, 724
marshaling common types, 723
shared memory, 727-730
simulating a C union, 726
Interface, 165
interface generic constraint, 101
interfaces, 1, 87-92
boxing and, 91
classes vs., when to use, 91
collections, 236
delegates vs., 109
explicit implementation, 88
extending, 88
extension methods, 145
getting interface implemented by a type, 565
IList, 238
implementing, 87
implementing members virtually, 89
reimplementing in a subclass, 89
alternatives to, 90
Interlocked class, 665
Intermediate Language (see IL)
internal (access modifier), 85
internal type with public members, 86
Internet addressing systems, 471
Interop attribute reference, 734-737
interpreted queries (LINQ), 300-306
AsEnumerable operator, 305
combining with local queries, 304
expression trees, 315
how they work, 302-304
execution, 302
querying SQL table, 301
interprocess communication (IPC), 441
Interrupt method, Thread class, 682
Abort method vs., 683
Intersect and Union methods (Permissions)
combining IPermission objects of same type, 614
combining permission sets, 615
Intersect query operator, 352
into keyword, 296, 299
scoping rules for query variables, 297
InvalidOperationException, 128, 482
invariant culture, 196
Invoke and BeginInvoke methods, 664
IP addresses, converting to domain names, 491
IP (Internet Protocol), 471
IPAddress class, 471
IPEndPoint class, 472
IPermission interface, 614
Demand method, 614
Intersect and Union methods, 614
IPrincipal interface, 626, 627
IPv4, 471
IPv6, 471
IQueryable<> interface, 300
is operator, 45, 75
IsAssignableFrom method, 566
ISerializable interface
binary serialization with, 522-525
interface definition, 522
subclassing serializable classes, 524
data contract serializers and, 516
IsInstanceOfType method, 566
isolated storage, 463-468
assembly and domain isolation, 464
enumerating
IsolatedStorageScope enum, 468
enumerating with IsolatedStorageFile, 467
isolated storage compartments, listed, 464
IsolatedStorageStream class, 463
isolation types, 463
locations of files, 466
reading and writing, 465
IsolatedStorageFileStream, 465
isolated thread data (nontransient), storing, 685
IsolatedStorageFilePermission class, 620
IsolatedStorageFileStream object, 464
IsolatedStorageScope enum, 465
IsSubclassOf method, 566
iteration, collections and, 230
iteration statements, 50-51
for loops, 50
while and do-while loops, 50
iteration variables, 283, 284
iterators, 131
composing sequences, 133
implementation of IEnumerable and IEnumerator, 232
iterator semantics, 132
IV (Initialization Vector), 631
IXmlSerializable interface, 499, 501, 533
data contract serializers and, 516
rules for implementing, 533
J[ Top ]
jagged arrays, 33
JIT (Just-In-Time) compiler, 3
inlining property accessors, 67
joining (query operators), 339-346
jump statements, 51
break, 51
continue, 52
goto, 52
return, 52
throw, 53
K[ Top ]
KeyedCollection<TKey,TItem> class, 265-267
ChangeItemForKey method, 265
GetItemForKey method, 265
implementation (example), 265
KeyValuePair structs, 258
keywords, 11
conflict with identifiers, avoiding, 12
contextual, 12
listing of C# keywords, 11
reference, 775-781
L[ Top ]
label statements, 52
labels
defining for branch target in IL, 589
lambda expressions, 118-121
as argument for query operators, 276
BNF form, 118
building, 317-319
code rewritten as statement block, 119
converting to method and calling the method through a delegate, 118
explicitly specitying parameter types, 119
generic, func delegates and, 119
outer variables, 120
lambda operator (=>), 45
lambda queries, 276-282
chaining query operators, 276-279
extension methods, 278
composing lambda expressions, 279-281
element typing, 280
Func signatures, 280
comprehension syntax vs., 285
ordering of input sequences, 281
LambdaExpression class, 317
Language Integrated Query (see LINQ)
languages
cultures and subcultures, 553
resource localization, 551
Last query operator, 356
LastNode property (LINQ to XML), 370
LastOrDefault query operator, 356
late binding, 573
lazy quantifiers, Regex, 761
left-associative operators, 43
length of arrays, 243
Length property of an array, 31
let keyword, 299
link demands (security), 621
LINQ (Language Integrated Query), 4, 274-319
building query expressions, 315-319
delegates vs. expression trees, 315-317
lambda expressions, 317-319
composing, 295-298
progressive query construction, 295
using into keyword, 296
wrapping queries, 297
comprehension queries, 282-286
iteration variables, 284
lambda syntax vs. comprehension syntax, 285
mixed syntax queries, 285
SQL syntax vs., 284
deferred execution queries, 286-292
chaining decorators, 290
how deferred execution works, 288
how they're executed, 291
outer variables, 287
reevaluation, 287
interpreted queries, 300-306
AsEnumerable operator, 305
combining with local queries, 304
how they work, 302-304
lambda queries, 276-282
chaining query operators, 276-279
composing lambda expressions, 279-281
LINQ (Language Integrated Query) (continued)
ordering of input sequences, 281
other operators, 281
operators, 320-361
projection strategies, 298-300
anonymous types, 299
let keyword, 299
object initializers, 298
queries, 275
query comprehension syntax, 276
query operator, 274
sequences and elements, 274
subqueries, 292-295
deferred execution and, 294
LINQ to SQL queries, 300, 306-314
associations, 310
combining interpreted and local queries, 304
DataContext object, 307
DataLoadOptions class, 312
deferred execution, 311
entity classes, 307
automatic generation, 309
translation of interpreted query to SQL, 302
updates to entities, 313
LINQ to XML, 362-394
documents and declarations, 379-382
DOM (Document Object Model), 362
X-DOM
instantiating, 366-369
navigating and querying, 369-373
overview, 363-366
updating an X-DOM, 373-376
values of elements and attributes, 376-379
<list> tag, XML, 156
lists
ArrayList class, 249
linked list, X-DOM nodes, 373
LinkedList<T> class, 250
adding node and specifying position, 251
removing elements, 251
ListDictionary class, 260
List<T> and ArrayList classes, 248
List<T> class, 238
Collection<T>, 262
properties and methods, 249
SortedList and SortedList<,> classes, 260
literals, 12
numeric, 21
integral literals, 21
numeric suffixes, 22
real literals, 21
suffixes, 22
type inference, 21
little-endian or big-endian order, 450
Load method, Assembly class, 555
LoadFile method, Assembly class, 555, 556, 558
LoadFrom method, Assembly class, 555, 556, 558, 560
local DateTimes, daylight saving and, 193
local host (IP address 127.0.0.1), 473
local queries (LINQ), 300
combining with interpreted queries, 304
delegates, 315
local sequences (LINQ), 274
local user compartments (isolated storage), 463
local variables, 8, 35, 46
generating dynamically, 588
implications of definite assignment, 36
implicitly typing with var, 41
instantiated within a lambda expression, 121
referenced by a lambda expression, 120
storage in the stack, 35
LocalApplicationData folder, 459
LocalDataStoreSlot object, 685
localization
cultures and subcultures, 553
of resources, 551
Visual Studio designer support, 553
locking, 654-660
atomicity and, 657
blocked threads awaiting a contended lock, 654
choosing synchronization object, 655
lock statement, 53, 654
Monitor class methods and, 655
memory barriers and volatility, 667
Mutex, 658
nested locking, 656
performance, races, and deadlocks, 657
ReaderWriterLockSlim, 690-694
upgradeable locks and recursion, 692-694
Semaphores, 659
thread safety and, 660
locking thread-safe objects, 662
manual vs. automatic locking, 661
using with types to make them thread safe, 661
when to lock, 656
logging, Windows event logs, 747-749
logical operators, 45
long date format, 187
long time, 187
long type, 21
lookahead and lookbehind assertions, 762
loop statements, 50
M[ Top ]
machine compartments (isolated storage), 464
MailMessage object, constructing, 492
managed code, 3
manifests
application, 535, 537
assembly, 535, 536
identity of an assembly, 542
ManualResetEvent class, 668
simulating with Wait and Pulse, 681
Marshal class
AllocHGlobal method, 431
FreeHGlobal method, 431
MarshalAs attribute, 723, 735
MarshalByRefObject class, Remoting and, 717
matched balanced constructs, 765
MatchEvaluator delegate, 766
Math class
methods, listed, 210
Round method, 207
Max query operator, 358
MD5 hash algorithm, 630
member cross-references in XML documentation comments, 157
member types, 570
retrieving metadata, 570
MemberInfo class, 568
DeclaringType property, 569
GetCustomAttributes method, 580, 583
GetMethod method, 571
Name property, 569
ReflectedType property, 569
subtypes, 570
members of a type, 14
instance members, 15
public, 16
static members, 15
MemberTypes enum, 568
memory
deallocation of (see garbage collection)
heap, 35
stack, 35
storage overhead for value types and reference types, 19
unmanaged, obtaining, 431
memory barriers, 667
memory management, 2
optimization, 429
MemoryStream class, 440
asynchronous method pattern and, 707
compressing entirely in memory, 462
Dispose method, 425
encrypting/decrypting in memory, 632
Message property, System.Exception, 127
message transmission mode (pipes), 443
metacharacters, regular expression, 759
metadata, 3
attached to types, members, and assemblies through attributes, 579
creating at runtime, 585
inspecting at runtime, using reflection, 562
retrieving member metadata, 570
metadata tokens, resolving, 579
MetadataToken property, 570
method overloading, inheritance and, 80
MethodAttributes enum, HideBySig value, 597
MethodBase class, GetParameters method, 574
MethodBuilder class
DefineGenericParameters method, 601
DefineMethod method, 595
DefineParameter method, 596
SetSignature method, 601
MethodHandle property, 570
MethodInfo class, 569
accessing MethodInfo objects associated with backing methods, 572
Invoke method, 573
IsSpecialName property, 572
MakeGenericMethod method, 576
methods, 2, 8, 61
anonymous, 121
dynamic, 585
passing arguments to, 587
dynamic invocations, 573
boosting performance with delegates, 574
method parameters, 573
emitting, 595
extension, 143-146
ambiguity and resolution, 144
chaining, 143
finalizers, 71
generic, 98
emitting, 601
invoking, 576
identifiers, 11
inlining, 67
input data from parameters, 9
overloading, 62
partial, 72
plug-in, writing with delegates, 106
retrieving metadata, 570
static, 15
virtual, overriding, 76
Microsoft Silverlight, 3
Min query operator, 358
mixed content nodes, values and (LINQ to XML), 378
MMC (Microsoft Management Console), 749
modifiers, compilation to bit-mapped attributes, 580
ModuleBuilder class, 592
modules, 538
emitting, 592
metadata token resolution, 579
multifile assemblies, 538
Monitor class
Enter and Exit methods, 655
TryEnter method, 655
Wait and Pulse methods, 673
mscorlib.dll, 159
mt tool (.NET), 538
multicast delegates, 106
example, 107
multidimensional arrays, 32
jagged arrays, 33
rectangular arrays, 32
multimedia timer, 696
Mutex class, 658
automatic release by CLR, 659
N[ Top ]
\n (newline), 29
naked type generic constraint, 101
named groups in regular expression matching, 765
named parameters (attributes), 147
named permission sets, 618
named pipes, 441-443
coordinating sending/receiving between client and server, 442
NamedPipeClientStream class, 442
NamedPipeServerStream class, 442
names
assembly, 542
AssemblyName class, 543
fully qualified, 543
resources, 547
namespaces, 10, 53-59
alias qualifiers, 58
aliasing types and, 57
extension method, 144
extern, 57
fully qualified names, 54
global namespace, 54
name hiding, 55
name scoping, 55
names, 382
namespace keyword, 53
namespace-to-assembly reference, 782-790
nested, 96
repeated, 56
specifying in XmlDocument, 413
declaring a namespace, 413
referring to a namespace, 413
using directive, 54
writing with XmlWriter, 406
XML, 403
specifying for XmlSerializer, 527
specifying with serialization attributes, 531
in XPath queries, 417
NamespaceURI and LocalName properties, 404
NaN (Not a Number), 26
native interoperability
(see also integrating with native DLLs)
navigating and querying X-DOM tree, 369-373
attribute navigation, 373
child node navigation, 369-372
parent navigation, 372
peer node navigation, 373
negative infinity, 26
negative