
C# ПІДРУЧНИКИ / c# / Apress - Accelerated C# 2005
.pdf
394■I N D E X
built-in types, 17 byte type, 18, 20
■C
C#
vs. C++/Java, 1–3
overview of syntax for, 15–32 C# 2.0, new features with, 4
anonymous methods, 243–253 generics, 257–293
interfaces, 203
iterator blocks, 216, 221–226 iterators, 203, 265
partial classes, 62 static modifier, 63 yield keyword, 216, 222
C++, 1–6, 98
C++ templates, vs. C# generics, 26, 258, 273, 276 callbacks, delegates for, 231–239 CallDelegates() method, 268
canonical forms, 339–390 reference types and, 339–380 value types and, 380–388
captured variables, caution for, 247–249 CAS (code access security), 225
case keyword, 30 catch block, 149
CER (constrained execution region), 162 chained delegates, 234–236 ChangeType() method, 372
char type, 18 circular iterators, 229
CirculatorIterator<T>() method, 230 class constraints, 277, 279
class definitions, 33–65 class keyword, 18, 33, 35, 62
class types, new keyword for, 79 classes
contract implementation and, 125 derived, 33
generic, 261–263 Clear() method, 211
Clone() method, 35, 177, 344 custom attribute for, 347
Close() method, 113, 171 closed types, 260
CLR (Common Language Runtime), 1, 7–13 accessibility and, 47
CLS (Common Language Specification), 9, 18 code, safe/unsafe techniques and, 21
code access security (CAS), 225 collection types, 210–217
efficiency and, 217 generics and, 26, 279 synchronizing, 212 Visual Basic and, 214
Collection<T> type, 214, 263 COM apartments, 308 COM development, 107
Combine() method, 234, 242
Common Language Runtime (CLR), 1, 7–13 accessibility and, 47
Common Language Specification (CLS), 9, 18 Common Type System (CTS), 18
Compare() method, 188 CompareExchange() method, 312, 314 CompareTo() method, 123, 366–369
type safety and, 386 comparison operators, 137 CompilerServices namespace, 162
CompletedSynchronously property, 331 ComplexNumber class, 368, 378 Console class, 3, 27, 64, 185
const keyword, 378
constrained execution region (CER), 162 constraints, 251, 274–279
constructed types, 260–274 control accessibility and, 273 creating dynamically, 291
constructors, 33, 38, 66–68, 79 instance, 38, 84–88
static, 38, 82–84 Consumer<T>, 261 Container identifier, 261 Container< Stack<T> >, 261 containment, 102–105 continue statement, 31
contracts, 107, 109, 125–131, 276
interface, vs. class implementation, 128–131 control flow, exceptions and, 148
conv IL instruction, 372 conversion, 50
conversion operators, 137, 140–142, 373 parameter types and, 133
Convert class, 119, 372 ConvertAll<TOutput>() method, 269 Converter<T, R> delegate, 265, 286 Converter<TInput, TOutput> delegate, 266 Copy() method, 177, 347
CopyTo() method, 212 CORBA development, 107 covariance, 204
Create() method, 188 CreateClosedType<T>() method, 292 CreateDelegate() method, 238, 252 CreateDelegates() method, 248 CreateEnumerator() method, 228 CreateInstance() method, 292 CreateReverseIterator<T>() method, 227 creating
arrays, 203 CERs, 162
constructed types, 291 CultureInfo, 181
custom exception classes, 168 delegates, 232–239 enumerators, 218–221 interfaces, 109–112

iterators, 221–230 jagged arrays, 209 objects, 79–88 threads, 296
critical finalizers, 162, 164–167 CriticalFinalizerObject, 164 cross-language compatibility, 12 crosscutting concerns, 21 CS1058 warning, 151
CTS (Common Type System), 18 culture names, 181 CultureAndRegionInfoBuilder class, 181 CultureInfo, 180, 188, 370
custom, 181
curly braces ({}), 245, 261 Current property, 218 CurrentCulture property, 369 CurrentThread property, 296
■D
data fields, declaring, 43–46 decimal type, 18
declaring namespaces, 28 data fields, 43–46 Decrement() method, 310
deep copies, objects and, 344, 348 default value expression, 269 default variable initialization, 22 Delegate class, 234, 251
delegate keyword, 232 delegates/delegation, 102–105, 231–239
anonymous methods and, 243–253 chained, 234–36
creating/using, 232–239 events, 239–243 generic, 266–269
open instance, 237–239 removing from lists, 234
derived classes, 33 destroying objects, 88–91 destructors
vs. finalizers, 351 reserved names and, 65
deterministic destruction, 90, 169, 173 diamond-lattice hierarchies, 110 dictionaries, 214
Dictionary<TKey, TValue> class, 280 Direction property, 228
disposable objects, 91–94, 349 Disposable pattern, 351
Dispose() method, 91–93, 113, 170, 221 deterministic destruction and, 351 finalizers and, 351–357
DLLs, 9
do statement, 30 DoSomeWork() method, 175, 255 double type, 18
DowngradeFromWriterLock() method, 325
■I N D E X 395
■E
efficiency |
|
|
boxing/unboxing and, 76 |
|
|
collection types and, 217 |
|
|
generics and, 259 |
|
|
encapsulation, 43–46 |
|
|
inheritance and, 103 |
|
|
encoding, strings and, 177, 189 |
|
|
EncodingGetByteCount() method, 190 |
|
|
EndInvoke() method, 330–333 |
|
|
EndProcessData() method, 298 |
|
|
Enter() method |
|
|
Monitor class, 317, 319 |
|
|
SpinLock class, 314 |
|
|
enumerations (enums), 20, 218–221 |
|
|
equality, 357–364 |
|
|
System.Object class and, 79 |
|
|
equality operators, 363 |
|
|
Equals() method, 79, 357–364 |
|
|
overriding, 361–364, 381–385 |
it Find |
|
escaped sequences, 178 |
||
event keyword, 241 |
||
EventHandler<T> class, 241 |
faster |
|
events, 65, 239–243, 326 |
||
|
||
exception handling, 90, 147–176 |
at |
|
custom exception classes and, 168 |
||
com/.apress.http://superindex |
||
exception naming conventions and, 168 |
||
|
||
exception-neutral code and, 157–167 |
|
|
mechanics of, 148–157 |
|
|
rollback behavior and, 173–176 |
|
|
unhandled exceptions and, 149 |
|
|
undefined behavior and, 90 |
|
|
working with exceptions and, 169–173 |
|
|
exception-neutral code, 157–167 |
|
|
structure of, 157–162 |
|
|
exception safety, 147–176 |
|
|
Exception.InnerException property, 153 |
|
|
Exchange() method, 311, 314 |
|
|
.exe files, 9 |
|
|
Exit() method, 317, 319 |
|
|
Expert pattern, 147 |
|
|
explicit interface implementation, 113, 122–124 |
|
|
explicit type conversion, 23, 34 |
|
|
expressions, 16 |
|
■F
Factor class, 247
family-and-assembly access modifier, 47 field modifiers, 35
fields, 35, 80
Finalize() method, 78, 88, 351 finalizers, 33, 70, 88, 351–357
advantages/disadvantages of, 357 critical, 162, 164–167
vs. destructors, 351 exceptions thrown in, 154 value types and, 381
finally block, 150 exceptions thrown in, 154





