1、Information technology Programming languages C#Technologies de linformation Langages de programmation C#INTERNATIONAL STANDARDISO/IEC23270Reference numberISO/IEC 23270:2018(E)Third edition2018-12 ISO/IEC 2018 ISO/IEC 23270:2018(E)ii ISO/IEC 2018 All rights reservedCOPYRIGHT PROTECTED DOCUMENT ISO/IE
2、C 2018All rights reserved.Unless otherwise specified,or required in the context of its implementation,no part of this publication may be reproduced or utilized otherwise in any form or by any means,electronic or mechanical,including photocopying,or posting on the internet or an intranet,without prio
3、r written permission.Permission can be requested from either ISO at the address below or ISOs member body in the country of the requester.ISO copyright officeCP 401 Ch.de Blandonnet 8CH-1214 Vernier,GenevaPhone:+41 22 749 01 11Fax:+41 22 749 09 47Email:copyrightiso.orgWebsite:www.iso.orgPublished in
4、 SwitzerlandISO/IEC 23270:2018(E)ISO/IEC 2018 All rights reserved iii Table of Contents Foreword.xix Introduction.xxi 1.Scope.1 2.Normative references.3 3.Terms and definitions.5 4.Acronyms and abbreviations.7 5.General description.9 6.Conformance.11 7.Lexical structure.13 7.1 Programs.13 7.2 Gramma
5、rs.13 7.2.1 General.13 7.2.2 Grammar notation.13 7.2.3 Lexical grammar.14 7.2.4 Syntactic grammar.15 7.2.5 Grammar ambiguities.15 7.3 Lexical analysis.16 7.3.1 General.16 7.3.2 Line terminators.16 7.3.3 Comments.17 7.3.4 White space.18 7.4 Tokens.19 7.4.1 General.19 7.4.2 Unicode character escape se
6、quences.19 7.4.3 Identifiers.20 7.4.4 Keywords.21 7.4.5 Literals.22 7.4.5.1 General.22 7.4.5.2 Boolean literals.23 7.4.5.3 Integer literals.23 7.4.5.4 Real literals.24 7.4.5.5 Character literals.25 7.4.5.6 String literals.26 7.4.5.7 The null literal.28 7.4.6 Operators and punctuators.28 7.5 Pre-proc
7、essing directives.28 7.5.1 General.28 7.5.2 Conditional compilation symbols.30 7.5.3 Pre-processing expressions.30 7.5.4 Definition directives.31 7.5.5 Conditional compilation directives.32 ISO/IEC 23270:2018(E)iv ISO/IEC 2018 All rights reserved 7.5.6 Diagnostic directives.34 7.5.7 Region directive
8、s.35 7.5.8 Line directives.35 7.5.9 Pragma directives.36 8.Basic concepts.37 8.1 Application startup.37 8.2 Application termination.38 8.3 Declarations.38 8.4 Members.41 8.4.1 General.41 8.4.2 Namespace members.41 8.4.3 Struct members.41 8.4.4 Enumeration members.42 8.4.5 Class members.42 8.4.6 Inte
9、rface members.42 8.4.7 Array members.42 8.4.8 Delegate members.42 8.5 Member access.42 8.5.1 General.42 8.5.2 Declared accessibility.42 8.5.3 Accessibility domains.43 8.5.4 Protected access.46 8.5.5 Accessibility constraints.47 8.6 Signatures and overloading.48 8.7 Scopes.49 8.7.1 General.49 8.7.2 N
10、ame hiding.52 8.7.2.1 General.52 8.7.2.2 Hiding through nesting.52 8.7.2.3 Hiding through inheritance.53 8.8 Namespace and type names.54 8.8.1 General.54 8.8.2 Unqualified names.56 8.8.3 Fully qualified names.56 8.9 Automatic memory management.57 8.10 Execution order.59 9.Types.61 9.1 General.61 9.2
11、 Reference types.61 9.2.1 General.61 9.2.2 Class types.62 9.2.3 The object type.62 9.2.4 The dynamic type.63 9.2.5 The string type.63 9.2.6 Interface types.63 9.2.7 Array types.63 9.2.8 Delegate types.63 9.3 Value types.63 9.3.1 General.63 ISO/IEC 23270:2018(E)ISO/IEC 2018 All rights reserved v 9.3.
12、2 The System.ValueType type.64 9.3.3 Default constructors.64 9.3.4 Struct types.65 9.3.5 Simple types.65 9.3.6 Integral types.66 9.3.7 Floating-point types.67 9.3.8 The decimal type.68 9.3.9 The bool type.69 9.3.10 Enumeration types.69 9.3.11 Nullable value types.69 9.3.12 Boxing and unboxing.70 9.4
13、 Constructed types.70 9.4.1 General.70 9.4.2 Type arguments.71 9.4.3 Open and closed types.71 9.4.4 Bound and unbound types.72 9.4.5 Satisfying constraints.72 9.5 Type parameters.73 9.6 Expression tree types.73 9.7 The dynamic type.74 10.Variables.77 10.1 General.77 10.2 Variable categories.77 10.2.
14、1 General.77 10.2.2 Static variables.77 10.2.3 Instance variables.77 10.2.3.1 General.77 10.2.3.2 Instance variables in classes.78 10.2.3.3 Instance variables in structs.78 10.2.4 Array elements.78 10.2.5 Value parameters.78 10.2.6 Reference parameters.78 10.2.7 Output parameters.79 10.2.8 Local var
15、iables.79 10.3 Default values.80 10.4 Definite assignment.80 10.4.1 General.80 10.4.2 Initially assigned variables.81 10.4.3 Initially unassigned variables.81 10.4.4 Precise rules for determining definite assignment.81 10.4.4.1 General.81 10.4.4.2 General rules for statements.82 10.4.4.3 Block state
16、ments,checked,and unchecked statements.82 10.4.4.4 Expression statements.82 10.4.4.5 Declaration statements.83 10.4.4.6 If statements.83 10.4.4.7 Switch statements.83 10.4.4.8 While statements.83 10.4.4.9 Do statements.83 ISO/IEC 23270:2018(E)vi ISO/IEC 2018 All rights reserved 10.4.4.10 For statements.84 10.4.4.11 Break,continue,and goto statements.84 10.4.4.12 Throw statements.84 10.4.4.13 Return statements.84 10.4.4.14 Try-catch statements.85 10.4.4.15 Try-finally statements.85 10.4.4.16 Try-