C# 3.0 in a Nutshell
C# 3.0 in a Nutshell, Third Edition A Desktop Quick Reference By Joseph Albahari, Ben Albahari
September 2007
Pages: 858

Cover | Table of Contents | Forum


Index


[ 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 lookahead assertions, 762
negative lookbehind assertions, 762
Negotiate authentication protocol, 479
nested types, 95
      names, 564
      obtaining, 564
      retrieving member metadata, 570
.NET Framework, xiv, 3, 159-169
      applied APIs, 159
      CLR-level functionality, 159
      compatibility with each version of C# and CLR, 159
      core types, 159
      mt tool, 538
      new features in Version 3.5, 161
      standard pattern for writing events, 113-116
      type namespace, 504
NetDataContractSerializer class (see data contract serializers)
NetworkCredential objects, 478
      contained in CredentialCache, 479
networking, 469-497
      addresses and ports, 471
      classes, key, 469
      HTTP-specific support, 482-486
            cookies, 484
            forms authentication, 485
            headers, 482
            query strings, 482
            SSL, 486
            uploading form data, 483
      network architecture, 469-471
            TLA (three-letter acronym) buster, 470
            types and communication layers, 469
      permissions types, 617
      receiving POP3 mail with TCP, 496-497
      request/response architecture, 474-482
            authentication, 478
            base classes, 474
            concurrency, 479
            exception handling, 481
            proxiess, 477
            WebClient class, 474
            WebRequest and WebResponse classes, 475
      sending mail with SmtpClient, 492
      URIs, 472
      using DNS, 491
      using FTP, 489-491
      using TCP, 493-496
      writing an HTTP server, 486-489
            web page server (example), 488
NetworkStream class, 495
new line sequence in Windows, 447
new modifier, 77
      virtual vs., 77
new operator, 44, 778
      creating anonymous types, 146
      creating new instance of a custom type, 15
      omitting in array initialization expressions, 33
nodes
      attribute, 402
      creating and manipulating, 412
      reading, 397
      value of, in XPath Data Model, 416
      writing, 405
      XmlLinkedNode class, 410
      XmlNode class, 410
Nodes method (LINQ to XML), 370
nonblocking synchronization, 664-667
      atomicity and Interlocked class, 664
      memory barriers and volatility, 666
nonpublic members, accessing, 574
[NonSerialized] attribute, 519
nonzero-based arrays, 241
NotImplementedException class, 128
NotSupportedException class, 128
null keyword, 779
null values
      data members, 510
      in equality comparisons for objects with Equals method, 217
      references, 19
      strings, 172
nullable types, 135
      alternatives to, 139
      bool? operands, use with & and | operators, 137
      boxing and unboxing nullable values, 136
      casting to, using with Element and Attribute methods, 377
      implicit and explicit nullable conversions, 135
      lifted operators, 136
            all other operators, 137
            equality operators, 137
            mixing nullable and nonnullable types, 137
            relational operators, 137
      null coalescing operator (??), 138
      Nullable<T> struct, 135
      scenarios for use, 138
      using with DateTime and DateTimeOffset, 188
NullReferenceException, 217
NumberFormatInfo class, 196
      using, 197
numbers
      conversions, 22, 209
      Math class, 210
      Random class, 210
NumberStyles enum, 197, 202
numeric format strings, 199
      custom, 201
numeric literals, type inference, 21
numeric suffixes, 22
numeric types, 20-27
      8- and 16-bit integral types, 25
      arithmetic operators, 23
      comparison operators, using, 28
      conversions, summary of, 209
      double vs. decimal, 27
      floating-point types, special values, 26
      increment and decrement operators, 24
      numeric literals, 21
      predefined in C#, listed, 20
      real number rounding errors, 27
      special float and double values, 26
      specialized integral operations, 24

O[ Top ]
Object class, 81-84
      Equals and GetHashCode methods, overriding, 141
      Equals method, 26, 216
      Finalize method, 71
      GetHashCode method, overriding, 220
      GetType method and typeof operator, 83
      members, listed, 84
      ReferenceEquals method, 218
      static and dynamic type checking, 82
      ToString method, 83
      using reflection to load all methods into sorted list, 261
      value types, casting to and from object, 81
object graphs, 498
      data contract serializer and, 500
      XmlSerializer and, 500
object initializers, 64
      projection strategy in LINQ queries, 298
      use in anonymous type creation, 146
object references (see references)
object type, 779
      boxing and unboxing, 82
      retreiving all nonpublic members, 575
ObjectDisposedException class, 128
object-orientation, key features of C#, 1
objects
      reference types, 18
      storage in the heap, 35
      storage overhead, 19
      tracking (DataContext), 308
OfType method, 250
OfType query operator, 353
[OnDeserializing] attribute, 514
      XmlSerializer and, 526
[OnSerialized] attribute, 514, 520
[OnSerializing] attribute, 514, 520
opcodes, 585
      Add, 587
      Br, Brtrue, and Blt (branching), 589
      Call or Callvirt, 590
      emitting with ILGenerator, 585
      Ldarg and Ldarg_XXX, 587
      Ldloc (load a local variable), 588
      loading into static dictionary, 607
      Newobj, 589
      pass-by-reference parameters, 596
      Ret (return), 585
      Rethrow, 591
      Stloc (store a local variable), 588
      Throw, 591
OpCodes class, 585
open type, 97
      typeof operator, using, 100
OpenFileDialog class, 617
operands, IL instructions, 607
      formatting, 609
      reading, 608
      short branch target, 610
operating systems
      C# support, 3
      security, 624-626
            standard user account, 624
operator functions, 140
operator keyword, 140, 779
operators, 9
      arithmetic, 23
      bitwise, 25
      C#, listed in order of precedence, 44
      checked, 24
      CLR translation of, 571
      defined, 12, 42
      enums, working with, 94
      lifted, use with nullable types, 136
            all other operators, 137
            equality operators, 137
            mixing nullable and nonnullable types, 137
            relational operators, 137
      overloading, 139-143
            equality and comparison operators, 141
            operator functions, 140
            true and false, 142
      pointer-to-member, 150
      precedence and associativity, 43
      retrieving metadata, 570
      unchecked, 25
      XPath, 415
optimizations
      inlining, 67
      memory management, 429
opt-in disposal pattern, 425
[OptionalField] attribute, 521
optionally disposable objects, 452
order comparisons, 175, 223-226
      < and > operators, 224
      binary search methods of arrays, 244
      IComparable interfaces, 223
            Equals method vs., 224
      implementing IComparable interfaces, 225
      plug-in, 268-273
            IComparer and Comparer, 270
            interfaces, 268
      sorting arrays, 245
      strings, 175
            culture-sensitive, case-sensitive comparison, 177
OrderBy query operator, 277, 346
      comprehension queries, 283
      signature, 281
OrderedDictionary class, 260
ordering operators, 346-348
ordinal comparisons (strings), 176
      case-sensitive comparison, 176
out keyword, 779
out modifier, parameters, 40
      getting multiple return values from a method, 40
out parameters
      emitting, 597
      passing to methods in dynamic invocation, 574
      type names, 565
outer variables, 120
      deferred execution queries, 287
output (see streams and I/O)
output sequence (LINQ), 274
overflow checking
      for constant expressions, 25
      integral arithmetic check operators, 24
OverflowException, 24
overloading
      constructors, 63
      methods, 62
overridden function members, accessing from subclass, 79
overridden modifier, events, 117
override keyword, 76, 779
overriding explicitly implemented interface members, 89
      alternatives to reimplementation, 90

P[ Top ]
pack size, 725
<para> tag, XML, 157
parallel execution, 479
      replacement with BackgroundWorker class, 708
<param> tag, XML, 155
ParameterizedThreadStart delegate, 643
parameterless base class constructor, implicit calling of, 80
parameterless constructor constraint, 101
parameters, 37-41
      attribute, 147
      delegate, compatibility of, 111
      generic, 97
            constraints on, 100
            declared for a generic method, 98
            declaring, 99
            delegate types, 108
      indexers, 69
      lambda expression, 317
            explicitly specifying types, 119
      method, 9
            retrieving metadata for, 573
      modifiers, 37
      out modifier, 40
      params modifier, 41
      pass-by-value vs. pass-by-reference, 62
      passing arguments by value, 38
      passing by reference, ref modifier, 39
      storage in the heap, 35
      variables as, 35
<paramref> tag, XML, 156
params keyword, 41, 779
parent navigation (X-DOM), 372
parent node, updating children through, 375
Parse method, 195
      numeric types, NumberStyles argument, 202
parsing
      DateTimeStyles flags enum, 205
      and misparsing DateTime format strings, 204
      numbers in base 2, 8, and 16 with Convert class methods, 207
      (see also formatting and parsing)
partial classes and methods, 72, 309
      partial keyword, 779
partially trusted callers, 621
passing by reference
      emitting pass-by-reference parameters, 596
      implications of, 40
      out parameters, 40
      ref parameters, 39
passing by value, 38
password changes, 454
password hashing, 630
paths
      Path class, 457
      URI, 472
            construction of, 473
peer node navigation (X-DOM), 373
performance
      array element type and, 32
      locking and, 657
performance counters, 749-754
      categories, 750
      creating counters and writing performance data, 753
      enumerating, 750
      reading data, 751
<permission> tag, XML, 155
permissions, 612-627
      authorization, 612
      code access, 616-618
            CLR allocation of permissions, 618
            diagnostics, 617
            encryption permissions, 617
            I/O and data, 616
            networking permissions, 617
      CodeAccessPermission class, 613
      declarative vs. imperative security, 615
      file, 455
      identity and role-based, 626
            assigning users and roles, 626
      IPermission interface, 614
      operating system security, 624-626
            standard user account, 624
      PermissionSet class, 615
      PermissionState enum, 615
      PrincipalPermission class, 613
      sandboxing, 612, 619-623
            another assembly, 620-623
            running in a sandbox, 619
persisting compressed data (GZipStream), 461
P/Invoke (Platform Invocation Services), 722
      callbacks from unmanaged code, 726
      (see also integrating with native DLLs)
PipeStream class, 441-445
      anonymous pipe subclasses, 442
      anonymous pipes, 444
      named pipe subclasses, 442
      named pipes, 442-443
PipeTransmissionMode, Message property, 443
placeholder types (generic types), 97
platform support, 3
pointers, 2, 148-151
      to arrays
            fixed-size buffers, 150
            stackalloc keyword, 150
      fixed statement, using, 149
      type names, 565
      to umanaged code, 151
      unsafe, 148
      void*, 151
pointer-to-member operator, 150
polymorphism, 74
POP (Post Office Protocol), 471
POP3 mail, receiving with TCP, 496-497
      helper method reading text line, 496
      helper method to send a command, 497
      retrieving mail, 497
Portable Executable (PE) file, 535
ports, 472
      POP3 port 110, 497
positional and named parameters (attributes), 147
positive infinity, 26
positive lookahead assertions, 762
positive lookbehind assertions, 762
#pragma warning directive, 153
precedence, operator, 43
predefined collection classes, 247
predefined types in C#, 20
predicate-based searching methods, arrays, 244
prefixes
      resources names, 547
      URI, use in WebRequest subclasses, 476
      XML elements and attributes
            reading with XmlReader, 403
            writing with XmlWriter, 406
preprocessor directives, 151, 738
      conditional attributes, 152
      pragma warning, 153
primary expressions, 42
primary operators, 44
primitive types
      building complex types from, 14
      default values, 37
      defined, 20
      instantiating, 15
PrincipalPermission class, 613, 626
principals, 626
priority, thread, 648
PriorityComparer class, 271
private (access modifier), 85, 779
      accessing private member from nested type, 95
PrivateBinPath property, AppDomainSetup class, 711
Process class, 228
processes, 745
      examining running processes, 745
      examining threads in, 745
      priority, 648
ProcessExit event, 712
ProcessStartInfo instance, 228
producer/consumer queue (threading), 676-678
      alternative to asynchronous methods, 708
program, 463
projecting object hierarchies, 327-339
projection strategies (LINQ queries), 298-300
      anonymous types, 299
      let keyword, 299
      object initializers, 298
properties, 2, 9, 65
      anonymous type, 146
      automatic, 67
      emitting, 597
      implementation by CLR, 67
      LINQ to SQL entity classes, 307
      metadata and backing methods, 571
            identitying backing methods, 572
      read-only and calculated, 66
      retrieving metadata, 570
PropertyBuilder class, SetGetMethod and SetSetMethod, 597
PropertyInfo class, 572
      GetValue and SetValue methods, 573
protected (access modifier), 85, 779
      applying to nested type, 96
protected internal (access modifiers), 86
ProtectedData class, 628
protocols
      network application layer, 469
      network transport layer, 469
ProtocolViolationException, 482
proxies
      list supplied to Collection<T>, 264
      network requests routed through proxy servers, 477
      ReadOnlyCollection<T> wrapper for a collection, 267
pseudocustom attributes, 580
public (access modifier), 16, 85, 779
public key cryptography, 635-638
      digital signing, 637
      public key and private key components, 635
      RSA class, 636
public key token (assemblies), 543
public members of an internal type, 86
public/private key pair, signed assemblies, 540
      checking for unreferenced assemblies, 561
      generating and storing, 540
      restricting access to, 541
punctuators, 12

Q[ Top ]
quantifiers
      query operator, 282, 359
      regular expression, 756
            greedy vs. lazy, 761
            listed, 760
queries, XML (see XPath)
query comprehension syntax, 276, 282
query operators (LINQ), 274, 320-361
      accepting two input sequences, 282
      aggregation operators, 282
      chaining, 276-279
            extension methods, 278
      deferred execution, 286-292
            chaining decorators, 290
            how it works, 288
            how queries are executed, 291
            operators not providing, 286
            outer variables, 287
            reevaluation, 287
      element operators, 281
      lambda expressions as arguments, 276
      lambda expressions, composing, 279-281
            element typing and lambda expressions, 280
            Func signatures, 280
      ordering of input sequences, 281
      other operators, 281
      quantifiers, 282
query strings, 482
Queryable class, 300
      interpreted query resolution to query operators in, 302
Queue and Queue<T> classes, 252

R[ Top ]
\r (carriage return), 29
races, lock, 657
Random class, 210
RandomNumberGenerator class, 632
Range query operator, 361
rank of arrays, 243
Read method, Stream class, 435
ReadByte method, Stream class, 436
ReaderWriterLockSlim class, 690-694
      example program, 690
      methods to obtain and release read/write locks, 690
      properties for monitoring locks, 692
      upgradeable locks and recursion, 692
readonly modifier, 779
      fields, 61
      static readonly fields, constants vs.,
            69
read-only properties, 66
ReadOnlyCollection<T> class, 267
real literals, 21
real number types, 21
real numbers
      rounding errors, 27
      rounding in real to integral conversions, 207
Realtime process priority, 648
rectangular arrays, 32
recursive functions returning child elements or nodes, 371
recursive locking, 693
red/black tree data structure, 260
reevaluation, deferred execution queries, 287
ref and out parameters
      external methods and, 725
      passing to methods in dynamic invocation, 574
      type names, 565
ref modifier, 39, 779
reference types, 17, 18
      array elements, 32, 242
      arrays, 32
      assigning a reference type variable, 18
      default value, 100
      equality comparisons, 28
      instance methods, calling in IL, 590
      instances, storage in memory, 35
      null coalescing operator (??), using with, 138
      null values, 19
      object, 81
      passing object by value, 38
      pointers to value typed declared within, 149
      predefined in C#, 20
      representing null reference, 135
ReferenceEquals method, Object class, 218
references, 18
      casting, 74
      polymorphic, 74
      serialization with data contract serializers, 507
      storage overhead, 20
referential equality, 215
      objects, comparing with == operator, 216
reflection
      defined, 562
      loading all methods in System.Object into sorted list, 261
reflection and metadata
      attributes, 579-584
            attribute basics, 579
            AttributeUsage attribute, 581
            defining your own, 581
            retrieving at runtime, 583
            retrieving in reflection-only context, 584
      awkward emission targets, 602-605
            circular dependencies, 603
            uncreated closed generics, 602
      dynamic code generation, 585-591
            generating IL with DynamicMethod, 585
            local variables, 588
      emitting assemblies and types, 592-595
            Reflection.Emit object model, 594
            saving emitted assemblies, 593
      emitting generic methods and types, 600-602
      emitting type members, 595-600
            attaching attributes, 600
            emitting constructors, 599
            emitting fields and properties, 597
            emitting methods, 595-597
      parsing IL, 605-611
            writing a disassembler, 606-611
      reflecting and activating types, 562-568
            base types and interfaces, 565
            generic types, 567
            instantiating types, 566
            obtaining a type, 562-564
            type names, 564
      reflecting and invoking members, 568-578
            accessing nonpublic members, 574
            C# vs. CLR members, 571
            dynamically invoking a member, 573
            generic methods, 576
            generic type members, 572
reflection and metadata (continued)
            generic type members, calling anonymously, 576
            member types, 570
            method parameters, 573
      reflecting assemblies
            loading into reflection-only context, 578
            modules, 579
Reflection.Emit object model, 594
regional variations of a language (subcultures), 553
regular expressions, 756-773
      alternator (|), 757
      character escapes, 759
      character sets, 759
      compiled, 757
      examples, 767-770
      groups, 764
      language reference, 770-773
      quantifiers, 756, 760
            greedy vs. lazy, 761
      Regex.Match method, 757
      Regex.Matches method, 757
      RegexOptions enum, 758
      replacing and splitting text, 765
      zero-width assertions, 761-764
            anchors, 762
            lookahead and lookbehind, 762
            word boundaries, 763
reimplementation of interface members, 89
      alternatives to, 90
relational operators, 45
      use with nullable types, 137
relative filenames, 438
relative URIs, 473
      resource files for applications, 551
<remarks> tag, XML, 155
Remoting, 717-718
Remoting and Web Services, 169
remove and add keywords, 117
Remove method (LINQ to XML), 375
Repeat query operator, 361
repeated namespaces, 56
Replace method (LINQ to XML), 375
ReplaceWith method (LINQ to XML), 375
replacing text (RegEx.Replace), 765
request/response model (networking), 474-482
      authentication, 478
      base classes, 474
      concurrency, 479
      exception handling, 481
      proxies, 477
      WebClient class, 474
      WebRequest and WebResponse classes, 475
resolution, assembly, 554
ResolveEventArgs event, 555
ResourceManager class, 550
      determining correct satellite assembly for a culture, 554
      getting contents of .g.resources container, 551
resources
      in assemblies, 535, 546
            .resources files, 546, 548
            .resx files, 549
            creating pack URI resource in Visual Studio, 550
            directly embedding, 547
            satellite assemblies, 551-553
      cultures and subcultures, 553
      embedded in an assembly, 559
      in assemblies
            reading .resource files, 550
restricted permission set applications, isolated storage, 463
.resx files, 549
      converting to .resources files, 552
      creating at the command line, 549
rethrowing exceptions, 122, 126
return statements, 52
return types, 9
      delegate compatibility, 111
      virtual and overridden methods, 76
<returns> tag, XML, 155
Reverse query operator, 281, 346
rich client applications
      thread safety, 663
right-associative operators, 44
Rijndael algorithm, 630
      disposing, 635
RIPEMD hashing algorithm, 630
roaming user compartments (isolated storage), 463
roles, 626
      assigning, 627
root element, XML document, 363
root object type, required by data contract serializer, 503
Round method, Math class, 210
rounding errors, float and double types, 27
RSA class, 636
runtime
      automatic memory management, 2
      dynamic type checking, 82
      type safety enforced, 2
Runtime Security Policy, 618

S[ Top ]
sandboxing, 2, 612
      another assembly, 620-623
            link demands and partially trusted callers, 621
            making assertions, 622
      code access permissions, 612
      running in a sandbox, 619
            optional permissions, 620
satellite assemblies, 546, 551-553
      building, 552
      localized .resources in different languages, 551
      testing, 553
SaveFileDialog class, 617
sbyte keyword, 779
sbyte type, 25
schema validation in XSD, 419-420
      validating with XmlReader, 419
      validating X-DOM or XmlDocument, 420
scheme (URIs), 472
scope
      names within a namespace, 55
      query variables following into keyword, 297
SDI (Single Document Interface) application, 664
sealed classes
      preventing interface reimplementation, 91
      relying on attributes for serialization, 524
sealed modifier, 780
      events, 117
sealing functions and classes, 78
security, 612-638
      code access, 616-618
      cryptography, 627-638
            hashing, 629
            public key encryption and signing, 635-638
            summary of options in .NET, 627
            symmetric encryption, 630-635
            Windows Data Protection, 628
      declarative vs. imperative, 615
      file, 455
      identity and role-based, 626
            assigning users and roles, 626
      isolated storage, 463
      .NET Framework
            main components, 612
      operating system, 624-626
            standard user account, 624
      permissions (see permissions)
      sandboxes, 2
      sandboxing, 619-623
            another assembly, 620-623
            running in a sandbox, 619
Security event log, 748
SecurityAction class, RequestOptional flag, 620
SecurityManager class, 620
SecurityPermissionFlag enum, 616
<see> tag, XML, 156
<seealso> tag, XML, 156
Seek method, Stream class, 436
Select query operator, 277, 328-332
      comprehension queries, 283
      ordering of input sequence, 281
      signature, 280
      subqueries within, 295
selection statements, 47
SelectMany query operator, 332
Semaphores, 659
      simulating with Wait and Pulse, 681
sequence of nodes or attributes, removing in X-DOM, 375
SequenceEqual method, Linq class, 561
sequences (LINQ), 274
      decorator sequences, 288
            chaining, 290
      ordering of input sequences, 281
[Serializable] attribute, 517
      interoperability with data contract serializers, 516
serializable types, 718
      subclassing, 524
serialization, 147, 498-534
      binary serialization attributes, 519-522
      binary serialization with ISerializable, 522-525
      binary serializer, 517-518
      data contract serializers, 502-511
            extending capabilities of, 513-517
      data contracts and collections, 511-513
      defined, 498
      explicit vs. implicit, 501
      serialization engines, 498
            binary serializer, 500
            comparison of, 499
            data contract serializer, 500
            implementing IXmlSerializable, 501
            reason for existence of three engines, 499
            XmlSerializer, 500
      uses of, 498
      X-DOM, 366
      XML, 525-534
            attribute-based serialization, 525
            collections, 530-532
            IXmlSerializable interface, 533
            subclasses and child objects, 528-530
            XDeclaration class and, 381
SerializationInfo class, 522
      typed "Get" methods for writing deserialization constructors, 523
ServerCertificateValidationCallback delegate, 486
ServicePointManager class, 486
set query operators, 352
sets, HashSet<T> class, 254
SHA256 hash algorithm, 630
shared memory, 727-730
shift operators, 45
short date, 187
short type, 25
short-circuit evaluation, conditional operators, 29
side-by-side execution, 546
signaling
      with event wait handles, 667-672
            creating and disposing wait handles, 669
            creating cross-process EventWaitHandle, 671
            pooling wait handles, 671
            static methods on WaitHandle class, 672
            two-way signaling, 669
      with Wait and Pulse, 673-682
            how to use Wait and Pulse, 673
            producer/consumer queue, 676-678
            simulating wait handles, 681
            two-way signaling, 679
            Wait timeouts, 678
signatures, method, 61
      asynchronous methods, 699
      MethodAttributes.HideBySig, 597
      overloaded methods, 62
      virtual and overridden methods, 76
signing, digital, 637
      signing assemblies, 540-542
            delay signing, 541
            how to sign, 540
Silverlight (Microsoft), 3
Simple Mail Transfer Protocol (see SMTP)
simple name (assemblies), 542
Single Document Interface (SDI) application, 664
Single query operator, 356
single-dimensional arrays, implicit typing, 34
SingleOrDefault query operator, 356
sizeof operator, 44
      use with enums, 94
Skip query operator, 281, 324
SkipWhile query operator, 327
slots (see data slots)
SMTP (Simple Mail Transfer Protocol), 471
      port 25, 472
SmtpClient class, 492
      constructing MailMessage object, 492
      DeliveryMethod property, 493
      Host property and Send method, 492
sn utility
      -p switch, 541
      -R switch, 542
      -Vr switch, 542
      -Vu switch, 542
SOAP
      formatters and, 501
SoapFormatter class, 518
Socket class, 493
SortedDictionary<,> class, 260
SortedList and SortedList<,> class, 260
sorting arrays, 245
source name (event logs), 748
SpecialFolder enum, 459
spinning (threads), 653
SpinWait method, Thread class, 653
splitting text (Regex.Split), 766
SQL
      LINQ comprehension syntax versus, 284
      (see also LINQ; LINQ to SQL queries)
SqlBoolean struct, 142
SqlMetal tool, 309
SSL (Secure Sockets Layer), 486
stackalloc keyword, 150, 780
stackalloc operator, 44
stacks, 35
      Stack and Stack<T> classes, 253
      Stack class implementation, 81
      Stack<T> generic type, 97
StackTrace and StackFrame classes, 746
StackTrace property, System.Exception, 127
standard format strings, 199
      numeric, 199
standard query operators (LINQ), 275
state, changing, 46
statement blocks, 8, 46
      lambda expression code as, 119
statements, 8, 46-53
      declaration, 46
      expression statements, 46
      fixed statement, pointers and, 149
      iteration statements, 50-51
            for, 50
            foreach, 51
            while and do-while, 50
      jump statements, 51
            break, 51
            continue, 52
            goto, 52
            return, 52
            throw, 53
      lock statement, 53
      selection statements, 47
      switch statements, 49
      using statement, 53, 125
static binding, 573
static classes, 71
static constructors, 70
      modifiers, 71
      nondeterminism of, 71
      static field initialization order, 71
static events, 117
static members, 15
      guaranteed to be thread safe, 662
static modifier, 780
      operator functions, 140
static readonly fields, constants vs., 69
static type checking, 82
static typing, 2
static variable flags vs. conditional compilation, 739
Stop method, 424
Stopwatch class, 754
stream adapters, 433, 446-452
      binary adapters, 450
      chaining (compression example), 462
      closing and disposing, 451
      text adapters, 446-450
            StreamReader and StreamWriter, 448
            StringReader and StringWriter, 450
StreamingContext class, 514
StreamReader and StreamWriter classes, 448
      character encodings, 449
streams and I/O
      backing store streams, 437
      BufferedStream class, 445
      closing and flushing streams, 436
      compression, 461-463
            compressing in memory, 462
            DeflateStream and GZipStream classes, 461
streams and I/O (continued)
      encryption streams, chaining with other streams, 633
      file and directory operations, 452-461
            Directory class, 456
            File class, 453-456
            FileInfo and DirectoryInfo classes, 456
            FileSystemWatcher class, 460
            Path class, 457
            special folders, 459
            volume information, querying with DriveInfo, 459
      FileStream class, 437-440
      I/O and data permissions, 616
      isolated storage, 463-468
            assembly and domain isolation, 464
            enumerating, 467
            isolated storage compartments, listed, 464
            IsolatedStorageStream class, 463
            isolation types, 463
            locations of files, 466
            reading and writing, 465
      MemoryStream class, 440
      NetworkStream class, 495
      PipeStream class, 441-445
      prohibiting all file I/O, 619
      reading and writing with streams, 435
      retrieving resource streams from assemblies, 547
      seeking, 436
      stream adapters, 446-452
            binary adapters, 450
            closing and disposing, 451
            text adapters, 446-450
      stream architecture, 432
            categories of streams, 433
      Stream class, 434
      stream timeouts, 437
      text encoding for file and stream I/O, 180
      thread safety, 437
      using stream to read, write, and seek, 434
      XmlReader, 396-404
      XmlWriter class, 404-406
String class, 172
      CompareTo method, 177
      Concat method, 174
      Contains, StartsWith, and EndsWith methods, 173
      Equals method, 175
      Equals method and == operator, CompareTo method vs., 224
      Format method, 174
      indexers, 67
      IndexOf method, 139
      Insert and Remove methods, 173
      IsNullOrEmpty method, 172
      LastIndexOf method, 173
      PadLeft and PadRight methods, 173
      Replace method, 174
      Split and Join methods, 174
      Substring method, 173
      ToCharArray method, 172
      ToUpper and ToLower methods, 174
      TrimStart and TrimEnd methods, 174
string concatenation operator (+), 30
string literals, 30
string type, 13, 30, 172
StringBuilder class, 178
      Append method, 178
      AppendLine and AppendFormat methods, 178
      Insert, Remove, and Replace methods, 178
      Length property, 178
StringComparer class, 272
StringComparison enum, 177
StringInfo class, 181
StringReader and StringWriter classes, 450
      Dispose method, 425
strings, 780
      accessing characters in, 172
      calling Substring method, statically and dynamically, 573
      comparing, 31, 175
            equality comparison, 175, 176
            order comparison, 175, 177
            ordinal and culture-sensitive comparisons, 176
      concatenation, 30
      constructing, 172
      conversion to URLs, 474
      converting enums to, 213
      converting from and to DateTime and DateTimeOffset, 187
      escape sequences, 29
      formatting (see formatting and parsing)
      Guids represented as, 215
      manipulating, 173
      null and empty, 172
      pointers to, within a fixed statement, 149
      receiving in .NET from unmanaged code, 723
      representation in a struct mapped to unmanaged memory, 732
      searching within, 173
      splitting and joining, 174
      ToString method, textual representation of a type instance, 83
      UTF-16 encoding and, 181
strong name (assemblies), 540
strongly typed language, 2
StrongName object, 623
struct generic constraint, 101
struct keyword
      defining a custom value type, 17
StructLayout attribute, 725, 734
structs, 84, 780
      casting to an interface, 91
      construction semantics, 85
      equality comparisons, 215
            customized, 219
            customizing, example, 222
      implementation of interfaces, 87
      implicit paramaterless constructors, 63
      mapping to unmanaged memory, 730-733
      marshaling, 724
      Nullable<T>, 135
      operators used on, 150
      simulating a C union, 726
subclasses
      constructors, declaring, 79
      inheritance from base class, 74
      reimplementing an interface in a subclass, 89
      serializing with data contract serializers, 505, 507
      XML serialization, 528
subclassing generic types, 102
subcultures, 553
      two-letter codes for, 553
subqueries (LINQ), 292-295
      deferred execution and, 294
      execution, 293
      within Select expression, 295
      wrapped queries vs., 298
subscribers, 112
suffixes, numeric, 22
Sum query operator, 358
<summary> tag, XML, 155
superclasses, 74
SurnameComparer class, 272
      culture-aware version, 273
surrogates (two-word Unicode characters), 181
switch keyword, 780
switch statements, 49
      using goto statement within, 52
symmetric encryption, 630
      chaining encryption streams, 633
      encrypting in memory, 632
synchronization object, 655
synchronization of threads, 652
      blocking, 652
      blocking vs. spinning, 653
      nonblocking, 664-667
            atomicity and Interlocked, 664
            memory barriers and volatility, 666
syntax, C#, 11-13
      comments, 13
      identifiers and keywords, 11
      literals, punctuators, and operators, 12
System event log, 748
System.Collection namespace, 31
System.Collections namespace, 262
System.Collections.ObjectModel namespace, 262
System.Data.Linq.Mapping namespace, 307
System.dll, System.Xml.dll, and System.Core.dll, 159
System.IO namespace, 432
      file and directory operations, 452
      networking classes, 469
System.IO.Compression namespace, 461
System.Linq namespace, 274
System.Linq.Expressions namespace, 274
System.Net.* namespaces, 469
System.Net.Mail namespace, 492
System.Reflection namespace, 562
System.Reflection.Emit namespace, 585
      essential types, 594
System.Security.AccessControl namespace, 455
System.Stirng class
      IndexOf method, 173
System.Type object
      GetType method, 83
      properties and methods, 83
System.Xml namespace, 395
System.Xml.Linq namespace, 362
System.Xml.XPath namespace, 414

T[ Top ]
\t (horizontal tab), 29
[Table] attribute, 307
Table<> class, 302
      InsertOnSubmit and DeleteOnSubmit methods, 313
Take query operator, 281, 324
TakeWhile query operator, 327
targets
      attribute, 148
      awkward emission targets, 602-605
            circular dependencies, 603
            uncreated closed generics, 602
      instance method, 108
TCP (Transmission Control Protocol), 471, 493-496
      addresses and ports, 472
      client request, basic structure, 493
      concurrency, 495
      coordinating client/server communication, 494
      receiving POP3 mail, 496-497
            helper method reading nonbuffered text line, 496
            helper method to send a command, 497
            retrieving mail, 497
      simple server (example), 494
      Socket class, 493
      TcpClient and TcpListener classes, 493
templates (C++) vs. C# generics, 103
temporary files created on construction, deleting, 429
ternary conditional operator (?:), 29
text adapaters
      StreamReader and StreamWriter
            character encodings, 449
text adapters, 446-450
      StreamReader and StreamWriter, 448
      StringReader and StringWriter classes, 450
text encodings, 179
      to and from byte arrays, 180
      encoding for file and stream I/O, 180
      legacy encodings, 179
      nonlegacy GB18030 standard for applications written in/sold to China, 179
      obtaining an Encoding object, 180
      UTF-16 and strings, 181
      UTF-8, UTF-16, and UTF-32, 179
TextReader class, 447
TextWriter class
      members, listed by category, 447
      ToString method, 448
ThenBy query operator, 346
this keyword
      identifying an indexer, 68
this reference, 64
thread safety, 660-664
      in application servers, 662
      approaches to implementation, 660
      .NET Framework types and, 661
            locking thread-safe objects, 662
            static members, 662
      in rich client applications, 663
      streams, 437
ThreadAbortException, 683
threading, 639-697
      application domains and threads, 714
      asynchronous delegates, 650
            starting worker task via, 650
      BackgroundWorker class, 686-690
            subclassing, 688
      creating threads, 640
      currently executing thread, 642
      ending threads, 641
      exception handling, 649
            cases in which .NET handles exceptions, 650
      foreground and background threads, 647
      Interrupt and Abort methods, 682-685
            Abort, 683
            Interrupt, 682
            safe cancellation, 684
      local storage, 685
      locks, 654-660
            choosing synchronization object, 655
            lock statement, 654
            locking and atomicity, 657
            Mutex, 658
            nested locking, 656
            performance, races, and deadlocks, 657
            Semaphores, 659
            when to lock, 656
      multithreading for TCP server, 495
      Name property of threads, 642
      nonblocking synchronization, 664-667
            atomicity and Interlocked, 664
            memory barriers and volatility, 666
      optimization of thread resources with asynchronous methods, 699
      parallel execution, 479
      passing data to threads, 642
      pausing with Thread.Sleep method, 642
      potential problems with, 640
      ReaderWriterLockSlim class, 690-694
            upgradeable locks and recursion, 692-694
      sharing data between threads, 643
            static fields, 645
            via a common reference, 644
      signaling with event wait handles, 667-672
      signaling with Wait and Pulse, 673-682
      starting a new thread, 641
      synchronization of threads, 652
            blocking, 652
            blocking vs. spinning, 653
      thread pooling, 645-647
            checking if current execution is on pooled thread, 645
            limiting number of worker threads, 645
            optimizing the pool, 646
      thread priority, 648
      threads and processes, 639
      threads in a process, 745
      timers, 694-697
            multithreaded timers, 695
            single-threaded, 696
      uses of, 639
      web page server (example), 489
      WebClient objects and, 475
ThreadInterruptedException, 682
ThreadPool class
      QueueUserWorkItem method, 645, 652
      RegisterWaitForSingleObject method, 671, 708
      SetMaxThreads method, 645
ThreadStart delegate, 640, 643
ThreadState enum, 652
      AbortRequested, 683
      WaitSleepJoin value, 655
throw statements, 53
time zones, 188-194
      DateTime and, 188
      DateTime objects, 184
      DateTimeOffset and, 189
      daylight saving and DateTime, 193
      handling by DateTime and DateTimeOffset, 183
      TimeZone class, 189
      TimeZone vs. TimeZoneInfo class, 189
      TimeZoneInfo class, 190-193
timeouts
      stream support for, 437
      WebReqeuest class, 481
      WebRequest, 476
timers, 694-697
      alternative to asynchronous methods, 708
      multithreaded, 695
            System.Threading namespace, 695
            System.Timers namespace, 695
      provided by .NET Framework, 694
      single-threaded, 696
TimeSpan struct, 181
      From- methods, 182
      Parse and TryParse methods, 183
      subtracting from a DateTime or DateTimeOffset, 187
      Total- properties, 182
      UTC offset specified as, in DateTimeOffset, 185
ToArray query operator, 287, 354
ToDictionary query operator, 355
ToList method, 250
ToList query operator, 287, 354
ToLookup query operator, 345, 355
ToString method, 83
      calling on an enum instance, 93
      calling on DateTime and DateTimeOffset, 187
      converting node content to XML string, 366
      default format provider, 196
      Enum class, 95
      formatting mechanism, 195
      TextWriter class, 448
TraceListener class, 742
tracing garbage collectors, 429
transforming XML languages, 421
Transform<T> generic method, 108
transition times (daylight saving), 192
transmitting compressed data (DeflateStream), 461
transport layer (networks), 469
      TCP and UDP protocols, 493
true and false operators, overloading, 140, 142
try method pattern for exceptions, 128
try statements, 122-130
      catch block, specifying type of exception to catch, 123
      catch clause
            multiple catch clauses to handle multiple exception types, 124
      code example, 122
      finally block, 125
            atomic operations and, 129
try/finally block, calling Dispose on IDisposable objects, 422
TryParse method, 195
two-word Unicode characters (surrogates), 181
type checking, static and dynamic, 82
Type class, 562
      BaseType property, 565
      GetCustomAttributes method, 580, 583
      GetInterfaces method, 565
      GetType method, 563
type compatibility, delegates, 110
type converters, 208
type inference
      inferring lambda parameter types, 119
      lambda expressions and query operator element typing, 280
      numeric literals, 21
type members, emitting, 595-600
      constructors, 599
      fields and properties, 597
      HideBySig method attribute, 597
      instance methods, 597
type safety, 2
      array bounds checking, 34
      dynamic binding and, 573
      enums, 94, 214
type unification, 81
TypeAttributes enum, 592
TypeBuilder class, 592
      CreateType method, 594, 604
      DefineField method, 597
      DefineGenericParameters method, 602
      DefineProperty method, 597
      methods to obtain members of uncreated closed generic types, 603
TypeConverter class, 209
TypeDescriptor class, GetConverter method, 209
typeof operator, 44, 563
      generics and, 100
      using on a type to get System.Type object, 83
TypeResolve event, 605
types, 13
      aliasing in namespaces, 57
      anonymous, 146, 299
      arrays, 31-35
      base types, 206
      bool types, 27
      C# and CLR, 3
      class, 10
      constructors and instantiation, 15
      conversions, 16, 141
      custom (examples), 14
      declaring within a namespaace, 53
      default values for instances, 37
      emitting, 592
      generic delegate, 108
      generic types names, standard LINQ query operators, 280
      identifiers, 11
      isolating, 718-721
      nested, 95
      nullable, 135
      numeric types, 20
      obtaining array types, 563
      predefined, 20
      predefined and custom, symmetry of, 15
      predefined (examples), 13
      resolution rules for, 554
      string types, 30
      thread safety and, 660, 661
      unififed type system, 1
      upcasting to object, 81
      value vs. reference types, 17
      XML type ID prefixes in comments, 157
      (see also reflection and metadata)

U[ Top ]
\u (or \x) escape sequence, specifying any Unicode character, 29
UAC (User Access Control), 624
      standard user account, 624
UDP (Universal Datagram Protocol), 471, 493
      addresses and ports, 472
unary operators, 44
      right-associativity, 44
UnauthorizedAccessException, 620, 625
unboxing and boxing, 82
UNC (Universal Naming Convention), 471
      paths, conversion to URIs, 473
unchecked operator, 25, 44
uncreated constructs
      restrictions on, 594
      uncreated closed generics, 602
#undef directive, 739
Unicode, 179
      \u or \x escape sequence, 29
      UTF-16 encoding, 181
            surrogates (two-word characters), 181
UnicodeCategory enumeration, 171
unified type system, 1
Union method
      combining permission sets, 615
      combining same-typed permission objects, 614
Union query operator, 282, 352
unions (C language), 726
unmanaged code
      pointers to, 151
      (see also integrating with native DLLs)
unmanaged memory, obtaining, 431
UnmanagedCode permission, 616
UnmanagedType enumeration, 723
      members, 736
unreferenced assemblies, 560
unsafe code, pointers and, 148-151
unsafe keyword, 148, 781
upcasting, 74, 75
      any type to object, 81
updates
      elements and attributes in X-DOM, 373-376
            child nodes and attributes, 374
            sequence of nodes or attributes, 375
            through the parent, 375
            value updates, 374
      LINQ to SQL entities, 313
      to shared assemblies, 546
      single-file executable application, 560
upgradeable locks, 692
URIs (Uniform Resource Identifiers), 471, 472
      converting strings to URLs, 474
      relative, 473
      resource files for applications, 550
      Uri class, 472
            constructing Uri objects, 473
      UriBuilder object, 473
URLs (Uniform Resource Locators), 471
User Access Control (UAC), 624
user interface technologies, 165
user-defined tags, XML, 157
ushort type, 25
using directive, 10
      importing a namespace, 54
      nested within a namespace, 57
using keyword, 781
using statement, 53
      closing and flushing DeflateStream, 462
      instantiating IDisposable object and calling its Dispose method in a finally block, 125
      shortcut for calling Dispose, using try/finally block, 422
UTC
      converting to or from in TimeZoneInfo class, 191
      current date and time returned by DateTime and DateTimeOffset, 186
      DateTime objects, 184, 189
      DateTimeOffset conversions to/from DateTime, 186
      DateTimeOffset objects, 189
      daylight saving and DateTime objects, 194
      offset specified for DateTimeOffset, 185
      TimeZone and TimeZoneInfo classes, 189
UTF-16 encoding, 449
UTF-8 encoding, 449
UTF-8, UTF-16, and UTF-32 text encodings, 179
utility classes
      Console class, 226
      Environment class, 227

V[ Top ]
\v (vertical tab), 29
value equality, 215
      applied by Equals method, Object class, 216
<value> tag, XML, 156
value types, 17
      array elements, 32, 242
      assignment of a value type instance, 17
      casting to and from object, 81
      custom, default value, 37
      default value, 100
      instance methods, calling in IL, 590
      instances, storage in memory, 36
      null values and, 135
      nullable, strategies for handling, 139
      pointers to, within a fixed statement, 149
      predefined in C#, 20
      storage overhead, 19
values
      element and attribute (X-DOM), working with, 376-379
            automatic XText concatenation, 378
            getting values, 377
            setting values, 376
            values and mixed content nodes, 378
      updates, X-DOM elements and attributes, 374
var keyword
      implicitly typed local variables, 41
      referencing an anonymous type, 146
      in simplified array initialization expressions, 34
variables, 13, 35-42
      changing, 46
      definite assignment, 36
      identifiers, 11
      outer variables, 120
      var, implicitly typing local variables, 41
verbatim string literals, 30
version tolerance, 500
      data contract serializers, 509
            required members, 509
versioning
      asembly version number
            getting with AssemblyName, 544
      assembly version number, 542
      binary serialization attribute [OptionalField} and, 521
      GAC (Global Assembly Cache) and, 544, 545
virtual function members, 76
virtual keyword, 76, 781
      events, 117
      new vs., 77
virtualization, 626
virtually implementing interface members, 89
Visual Studio LINQ to SQL designer, 309
void*, 151
void expressions, 42
void return types, 61
      multicast delegates, 107
volatility, locking and, 667

W[ Top ]
//W nonword characters in regular expressions, 763
//w word character in regular expressions, 763
W3C (World Wide Web Consortium), 395
Wait and Pulse signaling, 673-682
      disadvantages over event wait handles, 673
      how to use Wait and Pulse, 673
      producer/consumer queue, 676-678
      simulating wait handles, 681
      two-way signaling, 679
      Wait timeouts, 678
wait handles
      simulating with Wait and Pulse, 681
      (see also event wait handles)
WaitHandle class, 672
      SignalAndWait method, 672
      WaitAny and WaitAll methods, 672
warnings, compiler, 153
WCF (Windows Communication Foundation)
      data contract serializer, 499
      serialization engines and, 501
WebClient class, 474
      CancelAsync method, 480
      credential cache, using, 479
      Credentials property, 478
      download methods, 474
      exception handling, 481
      routing requests through a proxy server, 477
      running on parallel execution path, 479
      simple FTP uploads and downloads, 489
      upload methods, 475
      uploading form data, 483
      use of SSL, 486
WebException class, 481
WebExceptionStatus enum, RequestCanceled value, 480
WebProxy object, 477
WebRequest and WebResponse classes, 475
      canceling WebRequest operation from another thread, 480
      ContentLength property of WebResponse, 490
      CookieContainer object on WebRequest, 484
      Credentials property of WebRequest, 478
      exception handling, 481
      forms-based authentication with WebRequest, 485
      PreAuthenticate property on WebRequest, 479
      routing requests through proxy server, 477
      running WebRequest on parallel execution path, 479
      SSL use by WebRequest, 486
      uploading form data with WebRequest, 483
WebRequestMethods.Ftp, 490
      DeleteFile command, 491
      GetDateTimestamp command, 491
      GetFileSize command, 490
      Rename command, 491
Where query operator, 276, 277, 324
      comprehension queries, 283
      ordering of input sequence, 281
      resolution to Queryable.Where, 302
      signature, 280
while keyword, 781
while loops, 50
Win32 interop, determining if volume supports compression and encryption, 455
Windows
      authentication, 478
      event logs, 747-749
      isolated storage files, 466
      little-endian order for byte pairs, 450
      multimedia timer, 696
      new line sequence, 447
      pipes protocol, 441
      platform support for C#, 3
      Portable Executable (PE) file, 535
      special directories, 459
Windows Communication Foundation (see WCF)
Windows Communication Foundation (WCF), 168
Windows Data Protection, 628
Windows Forms, 166
      thread safety in, 663
      timer, 696
Windows Management Instrumentation (WMI) API, 454
Windows Presentation Foundation (see WPF)
Windows Vista
      isolated storage files, 466
      UAC (User Access Control), 624
Windows Workflow, 168
WMI (Windows Management Instrumentation) API, 454
word boundaries (regular expression), 763
WPF (Windows Presentation Foundation), 166
      thread safety in, 663
      timer, 696
wrapping LINQ queries, 297
Write and WriteLine methods, TextWriter class, 447
write-only properties, 66

X[ Top ]
\x escape sequence for any Unicode character, 29
XAML (Extensible Application Markup Language), 208
XAttribute class
      instantiating, 366
      properties and methods for attribute navigation, 373
      SetValue method (LINQ to XML), 374
      Value property, 374, 376
XContainer class, 364
      Add method, 366
      child node and attribute updates, 374
      Descendants and DescendantNodes methods, 371
      navigating and querying methods, 369
XDeclaration class, 365
XDocument class, 363, 365, 379
      Load and Parse methods, 365
      parent nodes and, 372
      Save method, 366
      ToString method, 366
X-DOM, 363-379
      executing XPath queries, 414
      instantiating, 366-369
            automatic deep cloning, 368
            functional construction, 367
            specifying content, 367
      loading and parsing, 365
      mixing with XmlReader/XmlWriter, 408
      navigating and querying, 369-373
      saving and serializing, 366
      types, 363
      updating, 373-376
            child nodes and attributes, 374
            removing sequence of nodes or attributes, 375
            through the parent, 375
            values of elements and attributes, 374
      validating XML file or stream in XSD, 420
      working with element and attribute values, 376-379
            automatic XText concatenation, 378
            getting values, 377
            mixed content nodes, 378
            setting values, 376
XElement class, 363
      child node and attribute updates, 374
      instantiating, 366
      Load and Parse methods, 365
      parent navigation, 372
      Save method, 366
      SetValue method (LINQ to XML), 374
      ToString method, 366
      using with XmlWriter, 410
      Value property, 374, 376
XHTML, transforming XML document into, 421
XML (eXtensible Markup Language)
      application manifest file, 537
      control over, for data contract serializers, 516
      documentation, 13
      documentation comments, 153-158
            predefined XML tags, 155-157
            type or member cross-references, 157
            user-defined XML tags, 157
      nodes, 397
      produced by DataContractSerializer, 502
      regular expression matching a simple element, 765
      transforming document into XHTML, 421
      (see also LINQ to XML)
XML Schema Definition (see XSD)
[XmlArray] attribute, 531
[XmlArrayItem] attribute, 531
[XmlAttribute] attribute, 527
XmlConvert class, 208, 401
XmlDocument class, 410-413
      creating and manipulating nodes, 412
      InnerText and InnerXml property, 412
      loading and saving, 411
      namespaces, 413
      traversing, 411
      validating in XSD, 420
XmlDoument class, 416
[XmlElement] attribute, 527
      child object subclassing and, 530
      serializing collections without outer element, 532
      specifying Order, 527
XmlElement attribute, applying to a class, 147
[XmlInclude] attribute, 529
XmlLinkedNode class, 410
XmlNamespaceManager class, 417
XmlNode class, 410
XmlNodeType enum, 397
XmlReader class, 396-404
      Create method, 450
      mixing with an X-DOM, 408
            using XmlReader with XElement, 409
      reading attributes, 402
            attribute nodes, 402
      reading elements, 399
            empty elements, 400
            optional elements, 400
            random element order, 400
            ReadXXX methods, 401
      reading nodes, 397
      schema validation, 419
XmlReader classs
      reading attributes
            namespaces and prefixes, 403
XmlReaderSettings object, 396
XmlSchemaValidationException, 419
XmlSerializer class, 499, 500, 525
      implementing IXmlSerializable, 533
      serializing child objects, 528
      serializing collections, 530-532
            subclassed collection elements, 532
      subclassing child objects, 529
      using for attribute-based serialization, 525-527
            attributes, names, and namespaces, 527
            recognized types with special treatment, 526
            XML element order, 527
XmlWriter class, 404-406
      mixing with an X-DOM, 408
            using XmlWriter with XElement, 410
      namespaces and prefixes, 406
      using with XSLT to output transformed documents, 421
      writing attributes, 405
      writing other node types, 405
XNode class, 363
      navigating and querying methods, 369
      peer node navigation methods and properties, 373
      updating child nodes through the parent, 375
XNodes class, 415
XObject class, 363
XPath, 414-417
      common operators, 415
      querying with namespaces, 417
      writing queries within code, 414
      XPathDocument class, 417
      XPathNavigator class, 416
            compiling query into XPathExpression, 416
XSD (XML Schema Definition), 418-420
      schema validation, performing, 419-420
            validating with XmlReader, 419
            validating X-DOM or XmlDocument, 420
XSLT, 421
      XslCompiledTransform class, 421
XText class
      automatic concatenation, 378
      values and, 378

Y[ Top ]
yield break statement in an iterator block, 133
yield return statement, 232

Z[ Top ]
zero-width assertions, 761-764
      anchors, 762
      lookahead and lookbehind, 762
      word boundaries, 763





Return to C# 3.0 in a Nutshell