Training
Certifications
Books
Special Offers
Community




 
Microsoft® C# Language Specifications
Author Microsoft Corporation
Pages 432
Disk N/A
Level All Levels
Published 04/25/2001
ISBN 9780735614482
ISBN-10 0-7356-1448-2
Price(USD) $29.99
To see this book's discounted price, select a reseller below.
 

More Information

About the Book
Table of Contents
Sample Chapter
Related Series
Related Books
About the Author

Support: Book & CD

Rate this book
Barnes Noble Amazon Quantum Books

 

Table of Contents


Prefacexvii
    Who Is This Book For?xvii
    What’s in This Book?xvii
    A Warningxviii
    About MSDNxviii
        MSDN Onlinexviii
        MSDN Publicationsix
        MSDN Subscriptionsix
1. Introduction1
    1.1 Getting started1
    1.2 Types2
        1.2.1 Predefined types5
        1.2.2 Conversions7
        1.2.3 Array types8
        1.2.4 Type system unification11
    1.3 Variables and parameters12
    1.4 Automatic memory management17
    1.5 Expressions20
    1.6 Statements21
    1.7 Classes24
        1.7.1 Constants27
        1.7.2 Fields27
        1.7.3 Methods29
        1.7.4 Properties30
        1.7.5 Events31
        1.7.6 Operators33
        1.7.7 Indexers35
        1.7.8 Instance constructors36
        1.7.9 Destructors37
        1.7.10 Static constructors38
        1.7.11 Inheritance38
    1.8 Structs40
    1.9 Interfaces41
    1.10 Delegates43
    1.11 Enums44
    1.12 Namespaces and assemblies45
    1.13 Versioning48
    1.14 Attributes51
2. Lexical structure53
    2.1 Phases of translation53
    2.2 Grammar notation53
    2.3 Lexical analysis54
        2.3.1 Input55
        2.3.2 Input characters55
        2.3.3 Line terminators55
        2.3.4 Comments55
        2.3.5 White space57
    2.4 Tokens57
        2.4.1 Unicode character escape sequences57
        2.4.2 Identifiers58
        2.4.3 Keywords60
        2.4.4 Literals61
            2.4.4.1 Boolean literals61
            2.4.4.2 Integer literals61
            2.4.4.3 Real literals62
            2.4.4.4 Character literals63
            2.4.4.5 String literals64
            2.4.4.6 The null literal66
        2.4.5 Operators and punctuators66
    2.5 Pre-processing directives66
        2.5.1 Pre-processing identifiers67
        2.5.2 Pre-processing expressions67
        2.5.3 Pre-processing declarations68
        2.5.4 #if, #elif, #else, #endif69
        2.5.5 #error and #warning72
        2.5.6 #region and #endregion73
        2.5.7 #line73
3. Basic concepts75
    3.1 Program Startup75
    3.2 Program Termination76
    3.3 Declarations76
    3.4 Members79
        3.4.1 Namespace members80
        3.4.2 Struct members80
        3.4.3 Enumeration members80
        3.4.4 Class members81
        3.4.5 Interface members81
        3.4.6 Array members81
        3.4.7 Delegate members81
    3.5 Member access81
        3.5.1 Declared accessibility82
        3.5.2 Accessibility domains83
        3.5.3 Protected access86
        3.5.4 Accessibility constraints87
    3.6 Signatures and overloading88
    3.7 Scopes89
        3.7.1 Name hiding92
            3.7.1.1 Hiding through nesting92
            3.7.1.2 Hiding through inheritance93
    3.8 Namespace and type names95
        3.8.1 Fully qualified names96
4. Types99
    4.1 Value types99
        4.1.1 Default constructors100
        4.1.2 Struct types101
        4.1.3 Simple types102
        4.1.4 Integral types103
        4.1.5 Floating point types104
        4.1.6 The decimal type106
        4.1.7 The bool type106
        4.1.8 Enumeration types107
    4.2 Reference types107
        4.2.1 Class types108
        4.2.2 The object type108
        4.2.3 The string type108
        4.2.4 Interface types108
        4.2.5 Array types108
        4.2.6 Delegate types109
    4.3 Boxing and unboxing109
        4.3.1 Boxing conversions109
        4.3.2 Unboxing conversions111
5. Variables113
    5.1 Variable categories113
        5.1.1 Static variables114
        5.1.2 Instance variables114
            5.1.2.1 Instance variables in classes114
            5.1.2.2 Instance variables in structs114
        5.1.3 Array elements114
        5.1.4 Value parameters115
        5.1.5 Reference parameters115
        5.1.6 Output parameters115
        5.1.7 Local variables116
    5.2 Default values116
    5.3 Definite assignment117
        5.3.1 Initially assigned variables120
        5.3.2 Initially unassigned variables120
    5.4 Variable references120
6. Conversions121
    6.1 Implicit conversions121
        6.1.1 Identity conversion121
        6.1.2 Implicit numeric conversions121
        6.1.3 Implicit enumeration conversions122
        6.1.4 Implicit reference conversions122
        6.1.5 Boxing conversions123
        6.1.6 Implicit constant expression conversions123
        6.1.7 User-defined implicit conversions123
    6.2 Explicit conversions123
        6.2.1 Explicit numeric conversions124
        6.2.2 Explicit enumeration conversions125
        6.2.3 Explicit reference conversions125
        6.2.4 Unboxing conversions126
        6.2.5 User-defined explicit conversions126
    6.3 Standard conversions127
        6.3.1 Standard implicit conversions127
        6.3.2 Standard explicit conversions127
    6.4 User-defined conversions127
        6.4.1 Permitted user-defined conversions127
        6.4.2 Evaluation of user-defined conversions128
        6.4.3 User-defined implicit conversions129
        6.4.4 User-defined explicit conversions130
7. Expressions131
    7.1 Expression classifications131
        7.1.1 Values of expressions132
    7.2 Operators133
        7.2.1 Operator precedence and associativity133
        7.2.2 Operator overloading134
        7.2.3 Unary operator overload resolution136
        7.2.4 Binary operator overload resolution136
        7.2.5 Candidate user-defined operators137
        7.2.6 Numeric promotions137
            7.2.6.1 Unary numeric promotions137
            7.2.6.2 Binary numeric promotions138
    7.3 Member lookup139
        7.3.1 Base types139
    7.4 Function members140
        7.4.1 Argument lists142
        7.4.2 Overload resolution145
            7.4.2.1 Applicable function member146
            7.4.2.2 Better function member147
            7.4.2.3 Better conversion147
        7.4.3 Function member invocation148
            7.4.3.1 Invocations on boxed instances149
        7.4.4 Virtual function member lookup150
        7.4.5 Interface function member lookup150
    7.5 Primary expressions150
        7.5.1 Literals150
        7.5.2 Simple names150
            7.5.2.1 Invariant meaning in blocks151
        7.5.3 Parenthesized expressions153
        7.5.4 Member access153
            7.5.4.1 Identical simple names and type names155
        7.5.5 Invocation expressions155
            7.5.5.1 Method invocations156
            7.5.5.2 Delegate invocations157
        7.5.6 Element access158
            7.5.6.1 Array access158
            7.5.6.2 Indexer access159
            7.5.6.3 String indexing160
        7.5.7 This access160
        7.5.8 Base access161
        7.5.9 Postfix increment and decrement operators161
        7.5.10 new operator162
            7.5.10.1 Object creation expressions163
            7.5.10.2 Array creation expressions164
            7.5.10.3 Delegate creation expressions166
        7.5.11 typeof operator168
        7.5.12 checked and unchecked operators169
    7.6 Unary expressions172
        7.6.1 Unary plus operator172
        7.6.2 Unary minus operator173
        7.6.3 Logical negation operator173
        7.6.4 Bitwise complement operator174
        7.6.5 Indirection operator174
        7.6.6 Address operator174
        7.6.7 Prefix increment and decrement operators174
        7.6.8 Cast expressions175
    7.7 Arithmetic operators176
        7.7.1 Multiplication operator177
        7.7.2 Division operator178
        7.7.3 Remainder operator179
        7.7.4 Addition operator180
        7.7.5 Subtraction operator182
    7.8 Shift operators183
    7.9 Relational operators185
        7.9.1 Integer comparison operators186
        7.9.2 Floating-point comparison operators186
        7.9.3 Decimal comparison operators187
        7.9.4 Boolean equality operators187
        7.9.5 Enumeration comparison operators188
        7.9.6 Reference type equality operators188
        7.9.7 String equality operators190
        7.9.8 Delegate equality operators190
        7.9.9 The is operator191
        7.9.10 The as operator192
    7.10 Logical operators193
        7.10.1 Integer logical operators193
        7.10.2 Enumeration logical operators194
        7.10.3 Boolean logical operators194
    7.11 Conditional logical operators194
        7.11.1 Boolean conditional logical operators195
        7.11.2 User-defined conditional logical operators195
    7.12 Conditional operator196
    7.13 Assignment operators197
        7.13.1 Simple assignment198
        7.13.2 Compound assignment200
        7.13.3 Event assignment201
    7.14 Expression201
    7.15 Constant expressions202
    7.16 Boolean expressions203
8. Statements205
    8.1 End points and reachability205
    8.2 Blocks207
        8.2.1 Statement lists208
    8.3 The empty statement208
    8.4 Labeled statements209
    8.5 Declaration statements210
        8.5.1 Local variable declarations210
        8.5.2 Local constant declarations211
    8.6 Expression statements212
    8.7 Selection statements212
        8.7.1 The if statement212
        8.7.2 The switch statement214
    8.8 Iteration statements218
        8.8.1 The while statement218
        8.8.2 The do statement219
        8.8.3 The for statement220
        8.8.4 The foreach statement221
    8.9 Jump statements223
        8.9.1 The break statement224
        8.9.2 The continue statement225
        8.9.3 The goto statement225
        8.9.4 The return statement227
        8.9.5 The throw statement227
    8.10 The try statement229
    8.11 The checked and unchecked statements232
    8.12 The lock statement232
    8.13 The using statement233
9. Namespaces237
    9.1 Compilation units237
    9.2 Namespace declarations238
    9.3 Using directives239
        9.3.1 Using alias directives240
        9.3.2 Using namespace directives243
    9.4 Namespace members245
    9.5 Type declarations245
10. Classes247
    10.1 Class declarations247
        10.1.1 Class modifiers247
            10.1.1.1 Abstract classes248
            10.1.1.2 Sealed classes248
        10.1.2 Class base specification249
            10.1.2.1 Base classes249
            10.1.2.2 Interface implementations250
        10.1.3 Class body251
    10.2 Class members251
        10.2.1 Inheritance252
        10.2.2 The new modifier253
        10.2.3 Access modifiers253
        10.2.4 Constituent types254
        10.2.5 Static and instance members254
        10.2.6 Nested types255
    10.3 Constants255
    10.4 Fields257
        10.4.1 Static and instance fields259
        10.4.2 Readonly fields259
            10.4.2.1 Using static readonly fields for constants260
            10.4.2.2 Versioning of constants and static readonly fields260
        10.4.3 Field initialization261
        10.4.4 Variable initializers261
            10.4.4.1 Static field initialization263
            10.4.4.2 Instance field initialization263
    10.5 Methods263
        10.5.1 Method parameters265
            10.5.1.1 Value parameters266
            10.5.1.2 Reference parameters266
            10.5.1.3 Output parameters267
            10.5.1.4 Parameter arrays269
        10.5.2 Static and instance methods272
        10.5.3 Virtual methods272
        10.5.4 Override methods275
        10.5.5 Sealed methods277
        10.5.6 Abstract methods278
        10.5.7 External methods280
        10.5.8 Method body281
        10.5.9 Method overloading281
    10.6 Properties282
        10.6.1 Static properties283
        10.6.2 Accessors283
        10.6.3 Virtual, sealed, override, and abstract accessors290
    10.7 Events292
        10.7.1 Event accessors294
        10.7.2 Static events296
        10.7.3 Virtual, sealed, override, and abstract accessors296
    10.8 Indexers297
        10.8.1 Indexer overloading300
    10.9 Operators301
        10.9.1 Unary operators302
        10.9.2 Binary operators302
        10.9.3 Conversion operators303
    10.10 Instance constructors304
        10.10.1 Constructor initializers306
        10.10.2 Instance variable initializers307
        10.10.3 Constructor execution307
        10.10.4 Default constructors309
        10.10.5 Private constructors310
        10.10.6 Optional constructor parameters310
    10.11 Static constructors311
    10.12 Destructors314
11. Structs315
    11.1 Struct declarations315
        11.1.1 Struct modifiers316
        11.1.2 Struct interfaces316
        11.1.3 Struct body316
    11.2 Struct members317
    11.3 Class and struct differences317
        11.3.1 Value semantics317
        11.3.2 Inheritance318
        11.3.3 Assignment318
        11.3.4 Default values319
        11.3.5 Boxing and unboxing320
        11.3.6 Meaning of this320
        11.3.7 Field initializers320
        11.3.8 Constructors321
        11.3.9 Destructors321
    11.4 Struct examples321
        11.4.1 Database integer type321
        11.4.2 Database boolean type323
12. Arrays325
    12.1 Array types325
        12.1.1 The System.Array type326
    12.2 Array creation326
    12.3 Array element access327
    12.4 Array members327
    12.5 Array covariance327
    12.6 Array initializers328
13. Interfaces331
    13.1 Interface declarations331
        13.1.1 Interface modifiers331
        13.1.2 Base interfaces332
        13.1.3 Interface body333
    13.2 Interface members333
        13.2.1 Interface methods334
        13.2.2 Interface properties335
        13.2.3 Interface events335
        13.2.4 Interface indexers335
        13.2.5 Interface member access336
    13.3 Fully qualified interface member names338
    13.4 Interface implementations339
        13.4.1 Explicit interface member implementations340
        13.4.2 Interface mapping342
        13.4.3 Interface implementation inheritance346
        13.4.4 Interface re-implementation348
        13.4.5 Abstract classes and interfaces350
14. Enums351
    14.1 Enum declarations351
    14.2 Enum modifiers352
    14.3 Enum members352
    14.4 Enum values and operations355
15. Delegates357
    15.1 Delegate declarations357
        15.1.1 Combinable delegate types358
    15.2 Delegate instantiation358
    15.3 Multi-cast delegates359
    15.4 Delegate invocation359
16. Exceptions361
    16.1 Causes of exceptions361
    16.2 The System.Exception class361
    16.3 How exceptions are handled362
    16.4 Common Exception Classes363
17. Attributes365
    17.1 Attribute classes365
        17.1.1 The AttributeUsage attribute365
        17.1.2 Positional and named parameters366
        17.1.3 Attribute parameter types367
    17.2 Attribute specification368
    17.3 Attribute instances371
        17.3.1 Compilation of an attribute372
        17.3.2 Run-time retrieval of an attribute instance372
    17.4 Reserved attributes373
        17.4.1 The AttributeUsage attribute373
        17.4.2 The Conditional attribute374
        17.4.3 The Obsolete attribute377
A. Unsafe code379
    A.1 Unsafe contexts379
    A.2 Pointer types381
    A.3 Fixed and moveable variables383
    A.4 Pointer conversions384
    A.5 Pointers in expressions384
        A.5.1 Pointer indirection385
        A.5.2 Pointer member access385
        A.5.3 Pointer element access386
        A.5.4 The address-of operator387
        A.5.5 Pointer increment and decrement388
        A.5.6 Pointer arithmetic389
        A.5.7 Pointer comparison389
        A.5.8 The sizeof operator390
    A.6 The fixed statement390
    A.7 Stack allocation393
    A.8 Dynamic memory allocation394
B. Interoperability397
    B.1 The ComAliasName attribute397
    B.2 The ComImport attribute397
    B.3 The ComRegisterFunction attribute398
    B.4 The ComSourceInterfaces attribute398
    B.5 The ComUnregisterFunction attribute399
    B.6 The ComVisible attribute399
    B.7 The DispId attribute400
    B.8 The DllImport attribute400
    B.9 The FieldOffset attribute401
    B.10 The Guid attribute402
    B.11 The HasDefaultInterface attribute402
    B.12 The ImportedFromTypeLib attribute403
    B.13 The In and Out attributes403
    B.14 The IndexerName attribute404
    B.15 The InterfaceType attribute404
    B.16 The MarshalAs attribute405
    B.17 The NoIDispatch attribute405
    B.18 The PreserveSig attribute406
    B.19 The StructLayout attribute406
    B.20 The TypeLibFunc attribute407
    B.21 The TypeLibType attribute407
    B.22 The TypeLibVar attribute407
    B.23 Supporting enums408
C. References411




Top of Page


Last Updated: Saturday, July 7, 2001