□Special Characters □A
Total Page:16
File Type:pdf, Size:1020Kb
INDEX ■Special Characters string concatenation, 122 #define, 275 subtraction, 122 #elif, 275 unary minus, 121 #else, 275 unary plus, 121 #endif, 275 array parameters, overloading, 58–60 #if, 275 Array class, 293–294 #line, 277 arrays, 42–45 #pragma warning disable, restore, 278 conversions, 143–144 #region, 277 default size, 139 #undef, 275 description, 139 #warning, 277 initialization, 139 += operator, 221 jagged, 139, 141–142 = operator, 221 jagged or multidimensional, 15 multidimensional, 139–140 ■A rectangular, 140 Abort( ) method, multithreading, 419 reference types, 142–143 abstract members, compared with Reverse function, 144 interfaces, 85–86 sorting and searching functions, 144 abstract classes, 2, 48–51 System.Array type, 144 access reordering, 324, 326 as operator and interfaces, 88–89 accessibility of properties, 175–176 assemblies, listing types in, 465–466 accessors, 169–170 Assembly.LoadFrom( ) deployment, 444 add and remove functions, 230–238 asserts, 474–475 AddClick( ) method, 230–233 assignment operators, 125 AddEntry( ) function, updating Registry, 438 compound assignment, 125 advanced hashes, 306, 308–309 simple assignment, 125 aggregation (containment), in asynchronous operations and threading, object-oriented systems, 2 315–340 aliases, assembly name qualifier, 101–104 asynchronous calls, 331 anonymous methods, 225–227 example showing BeginInvoke( ), Append( ) method, StringBuilder class, 160 EndInvoke( ) functions, 333–334 AppendFormat( ) method, StringBuilder using delegates for multithreading, 332 class, 160 attributes, 17, 202 arithmetic operators, 121 designing, 211–212 addition, 121 finding values of, 213–215 bitwise complement, 121 multiuse, 210 division, 122 overview, 207 increment and decrement, 123 parameters of, 212–213 multiplication, 122 and relection, 213–215 remainder, 122 using, 208–211 shift, 123 AttributeTargets enumerator, 211 517 518 ■INDEX AttributeUsage attribute, 209, 211 catch block processing, in exception autocompletion, Visual Studio .NET, 17 handling, 22–24 AutoResetEvent, ManualResetEvent class, character literal, 281 threads, 330–331 checked and unchecked expressions, 128 checked context, 132–133 ■B checked/unchecked statement, 112 base classes class keyword, 15 and arrays, 42–45 class view, Visual Studio .NET, 18 Engineer class example, 39–40 classes in inheritance, 1 abstract, 48–51 and simple inheritance, 40–41 accessibility and virtual functions, 46–48 hierarchical resolution of method basic data types, 13 overloading, 56–57 BeginGetResponse( ) function, interaction with member accesibility, 55 asynchronous processing, 340 internal modifier, 53 BeginInvoke( ), EndInvoke( ) functions, internal modifier with class members, asynchronous calls, 332 53–54 BidirectionalSubrange method, 194 internal protected modifier with class BinaryReader and BinaryWriter classes, 389 members, 55 bit flag enumerations, 202 nested classes, 61–62 boolean literal, 280 public modifier, 53 boxing and unboxing, 14–15, 80–81, 146–147, base classes 501–502 and arrays, 42–45 built-in data types, 14 Engineer class example, 39–40 built-in operators, 120 and simple inheritance, 40–41 Button class, 230, 235 and virtual functions, 46–48 ButtonHandler, 230 breaking into parts (partial classes), 76–77 Button.TearDown( ), 238 creation, initialization, destruction, 62–66 ■C destruction, 65 finalizers and non-memory resources, 66 C#. See also programming languages, initialization, 65 comparison to C/C# and member functions, 33 development options for, 17 nesting, 61–62 resources and out parameters, 36 Code Project, 516 and pre- and post-conversions, 247–253 CodeGuru, 515 and reference (ref) parameters, 33–35 C-Sharp Corner, 515 sealed, 51 DotNet Books, 516 simple class example, 31–33 GotDotNet, 515 singleton, 64–65 MSDN, 515 ClearDelegates( ) method, 238 Pinvoke.NET, 516 ClickHandler delegate, 230 C# command line compiler (csc), 17 ClickOnce, 443–445, 447 calling program exception handling, 25–27 CLS compliance, 450–451 camelCasing, 449 ClsCompliant assembly attribute, 450–451 Capacity property, StringBuilder class, 160 ClsCompliant attribute, 211 case-insensitive collections, cluster size calculations on disk, 441–443 CreateCaseInsensitiveSortedList( ), CodeDOM, execution time code generation, CreateCaseInsensitiveHashtable( ) 354–355, 357 functions, 309 CodeReviewAttribute, 209, 214 ■INDEX 519 collections, in .NET Framework, 311–312 ■D command-line compiler DataRow class, 181 default response file, csc.rsp, 493 DateTime class formats, 385 option parameters, 494–496 Debug and Trace classes, 474–475, 477 overview, 493 BooleanSwitch, 477–478 response files, 493 custom switches, 480–481, 483 simple usage, 493 TraceInformation( ), capturing process command-line compiler for C#, 17 metadata, 483–484 comments, 282 TraceSwitch, 478, 480 Common Language Runtime (CLR), 5 debugger, Visual Studio .NET, 18 Compare( ), string operation, 157 decimal point format string character, 381 CompareOrdinal( ), string operation, 157 defensive programming, overview, 473 CompareTo( ), string operation, 157 definite assignment, 114–117 comparison to C/C#, 64 with arrays, 116 Compiled option, RegEx class, 162 with structs, 115–117 compile-time compared with execution Delegate class, 220 time, 341 DelegateCache class, 238 Complex class, 209 Delegate.Combine( ), 220–221 complex parsing, example program, Delegate.Remove( ), 221 163–164, 166 delegates, 16 Component Object Model (COM), and multicasting, 220–221 disadvantages, 5 as static members, 222–223 Concat( ), string modification method, 158 as static properties, 223–225 conditional methods, Conditional attribute, using, 217–219 473–474 delegateStore hash table, 235 Configuration file, updating, 439, 441 derived class, in inheritance, 1 const, knowable at compile time, 72–73 design guidelines constants, 72 for exception handling, 30 constraints, 148–149 for virtual functions and interfaces, 312 constructed type, in generics, 147–148 destruction, 65 constructor, private, 64–65 development options for C#, 17 constructors digit or space placeholder format string creation and initialization, 62–64 character, 380 in exception handling, 28 digit or zero placeholder format string containment (aggregation), role in character, 380 object-oriented systems, 2 disposable enumerators, 191–192 conversions, 129–138. See also user-defined Dispose( ), 66–69, 191 conversions DotGNU, 443 checked, 132–133 and overloaded functions, 130–132 ■E conversions, class, 133 encapsulation, 4 base class, 134–135 EndGetResponse( ) function, asynchronous interface, 135 processing, 340 interface implementations, 135, 137 EndInvoke( ) potential problem, 337, 339 between interface types, 137 EndsWith( ), string operation, 157 conversions, structs, 137 Engineer class example, 39, 40 CopyTo( ), string modification method, 158 EnsureCapacity( ) method, StringBuilder currency standard format string, 376 class, 160 custom format strings, 379–385 520 ■INDEX enumerations, 15 overview, 341 base types, 200 Reflection.Emit class creation in memory, bit flag enums, 202 357, 359–361 conversions, 202–203 secondary application domain, 361, 363 initialization, 201 using CodeDOM to create code, line-style, 199–200 354–355, 357 overview, 199 explicit conversions, 129, 132 System.Enum type, 203–205 explicit interface implementation, 92–94 enumerators. See also indexing ExplicitCapture option, RegEx class, 162 disposable, 191–192 exponential notation format string, 383 and foreach statement, 185–189 extern alias improving, 189–191 external assembly alias, 102–104 and iterators, 192–198 reference switch, 103–104 environment settings, System.Environment external assembly alias, 101–104 class, 400–402 Equals( ) function, 285–286, 289–292 ■F escapes and literals, in format strings, 384 finalizers and non-memory resources, 66 EventArgs, 233 finally exception block, in exception events, 16 handling, 28, 30 add and remove functions, 230–238 FindColumn( ), 183 overview, 229–230 fixed-point format string, 377 exception handling ForEach method, of Array, 227 Caller Beware, 25 foreach statement, 185–189 Caller Confuse, 25–26 form designer, Visual Studio .NET, 18 Caller Inform, 25–27 Format( ), 159 calling program processing, 25–27 function pointers, 217, 219 catch block processing, 22–24 functions design guidelines, 30 and interfaces by .NET Framework finally exception block, 28, 30 class, 313 garbage collection and efficiency, 30 member functions, 33 hierarchical processing, 22–24 overloaded, 4, 36–37 overview, 22 performing same action, but with different type of exception matching, 22 parameters, 36–37 user-defined classes, 27–28 virtual, 46–48 execution time code generation future of C#, 516 self-modifying code polynomial FxCop programming tool, 491 evaluation example, 344–361 ■G casting class instance to an interface, 353 garbage collection class instantiation using .NET CLR, concurrent, 463–465 341–343 controlling, 463 custom class for self-modifying code, and efficiency in exception handling, 30 350–352 finalization (destructors), 65–66, 462, 463 dynamic execution time assembly generations, 461–462 discovery, 343–344 heap allocation, 460 eliminating compiler dependency, Mark and Compact algorithm, 460 354–355, 357 overview, 460 faster custom class for self-modifying server vs. workstation, 463–465 code, 353 general format string, 378 lightweight code generation model, 361, 363 generic collections, in .NET Framework, 312 ■INDEX 521 generic comparison interfaces, IComparable interface, 294–295 IComparable, IComparer, 302, IComparer interface,