Skip to content

Latest commit

 

History

History
44 lines (40 loc) · 3.95 KB

ii.7.1-types.md

File metadata and controls

44 lines (40 loc) · 3.95 KB

II.7.1 Types

The following grammar completely specifies all built-in types (including pointer types) of the CLI system. It also shows the syntax for user defined types that can be defined in the CLI system:

Type ::= Description Clause
'!' Int32 Generic parameter in a type definition, accessed by index from 0 §II.9.1
| '!!' Int32 Generic parameter in a method definition, accessed by index from 0 §II.9.2
| bool Boolean §II.7.2
| char 16-bit Unicode code point §II.7.2
| class TypeReference User defined reference type §II.7.3
| float32 32-bit floating-point number §II.7.2
| float64 64-bit floating-point number §II.7.2
| int8 Signed 8-bit integer §II.7.2
| int16 Signed 16-bit integer §II.7.2
| int32 Signed 32-bit integer §II.7.2
| int64 Signed 64-bit integer §II.7.2
| method CallConv Type '*' '(' Parameters ')' Method pointer §II.14.5
| native int 32- or 64-bit signed integer whose size is platform-specific §II.7.2
| native unsigned int 32- or 64-bit unsigned integer whose size is platform-specific §II.7.2
| object See System.Object in Partition IV  
| string See System.String in Partition IV  
| Type '&' Managed pointer to Type. Type shall not be a managed pointer type or typedref §II.14.4
| Type '*' Unmanaged pointer to Type §II.14.4
| Type '<' GenArgs '>' Instantiation of generic type §II.9.4
| Type '[' [ Bound [ ',' Bound ]*] ']' Array of Type with optional rank (number of dimensions) and bounds. §II.14.1 and §II.14.2
| Type modopt '(' TypeReference ')' Custom modifier that can be ignored by the caller. §II.7.1.1
| Type modreq '(' TypeReference ')' Custom modifier that the caller shall understand. §II.7.1.1
| Type pinned For local variables only. The garbage collector shall not move the referenced value. §II.7.1.2
| typedref Typed reference (i.e., a value of type System.TypedReference), created by mkrefany and used by refanytype or refanyval. §II.7.2
| valuetype TypeReference (Unboxed) user defined value type §II.13
| unsigned int8 Unsigned 8-bit integer §II.7.2
| unsigned int16 Unsigned 16-bit integer §II.7.2
| unsigned int32 Unsigned 32-bit integer §II.7.2
| unsigned int64 Unsigned 64-bit integer §II.7.2
| void No type. Only allowed as a return type or as part of void * §II.7.2

In several situations the grammar permits the use of a slightly simpler representation for specifying types; e.g., "System.GC" can be used instead of "class System.GC". Such representations are called type specifications:

TypeSpec ::= Clause
'[' [ .module ] DottedName ']' §II.7.3
| TypeReference §II.7.2
| Type §II.7.1