Skip to content

Commit d9fd9bd

Browse files
committed
Edit pass on nint
Proofread and edit pass.
1 parent 52f0560 commit d9fd9bd

4 files changed

Lines changed: 11 additions & 18 deletions

File tree

standard/conversions.md

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,8 @@ An implicit constant expression conversion permits the following conversions:
324324
- A *constant_expression* ([§12.25](expressions.md#1225-constant-expressions)) of type `int` can be converted to type `sbyte`, `byte`, `short`, `ushort`, `uint`, `nint`, `nuint`, or `ulong`, provided the value of the *constant_expression* is within the range of the destination type.
325325
- A *constant_expression* of type `long` can be converted to type `ulong`, provided the value of the *constant_expression* is not negative.
326326
327+
The range for constants of `nint` is the same range as `int`. The range of constants for `nuint` is the same range as `uint`.
328+
327329
### 10.2.12 Implicit conversions involving type parameters
328330
329331
For a *type_parameter* `T` that is known to be a reference type ([§15.2.5](classes.md#1525-type-parameter-constraints)), the following implicit reference conversions ([§10.2.8](conversions.md#1028-implicit-reference-conversions)) exist:
@@ -763,17 +765,6 @@ Conversion from `A` to `Nullable<B>` is:
763765
- an explicit nullable conversion if there is an explicit conversion from `A` to `B`;
764766
- otherwise, invalid.
765767
766-
Conversion from `Nullable<A>` to `B` is:
767-
768-
- an explicit nullable conversion if there is an identity conversion or implicit or explicit numeric conversion from `A` to `B`;
769-
- otherwise, invalid.
770-
771-
Conversion from `Nullable<A>` to `Nullable<B>` is:
772-
773-
- an identity conversion if there is an identity conversion from `A` to `B`;
774-
- an explicit nullable conversion if there is an implicit or explicit numeric conversion from `A` to `B`;
775-
- otherwise, invalid.
776-
777768
### 10.6.2 Lifted conversions
778769
779770
Given a user-defined conversion operator that converts from a non-nullable value type `S` to a non-nullable value type `T`, a ***lifted conversion operator*** exists that converts from `S?` to `T?`. This lifted conversion operator performs an unwrapping from `S?` to `S` followed by the user-defined conversion from `S` to `T` followed by a wrapping from `T` to `T?`, except that a null valued `S?` converts directly to a null valued `T?`. A lifted conversion operator has the same implicit or explicit classification as its underlying user-defined conversion operator.

standard/expressions.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,6 @@ When overload resolution rules ([§12.6.4](expressions.md#1264-overload-resoluti
291291

292292
> *Example*: For the operation `b * s`, where `b` is a `byte` and `s` is a `short`, overload resolution selects `operator *(int, int)` as the best operator. Thus, the effect is that `b` and `s` are converted to `int`, and the type of the result is `int`. Likewise, for the operation `i * d`, where `i` is an `int` and `d` is a `double`, `overload` resolution selects `operator *(double, double)` as the best operator. *end example*
293293
294-
There are no predefined operators for dealing with native integer ([§8.3.6]( types.md#836-integral-types)). Instead, `nint` and `nuint` values shall be promoted to `long` and `ulong`, respectively, and the resulting corresponding predefined operators used instead.
295-
296294
**End of informative text.**
297295

298296
#### 12.4.7.2 Unary numeric promotions

standard/lexical-structure.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,9 @@ The type of a *boolean_literal* is `bool`.
664664

665665
#### 6.4.5.3 Integer literals
666666

667-
Integer literals are used to write values of types `int`, `uint`, `long`, and `ulong`. (There is no way to write values of type `nint` and `nuint`. Instead, implicit or explicit casts of other integral constant values may be used.) Integer literals have three possible forms: decimal, hexadecimal, and binary.
667+
Integer literals are used to write values of types `int`, `uint`, `long`, and `ulong`. Integer literals have three possible forms: decimal, hexadecimal, and binary.
668+
669+
> *Note:* There is no way to write literal values of type `nint` and `nuint`. Instead, implicit or explicit casts of other integral constant values may be used. *end note*
668670
669671
```ANTLR
670672
Integer_Literal

standard/types.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,9 @@ Every simple type has members. Each simple type that is an alias for a predefine
319319
>
320320
> *end note*.
321321
322-
Although `nint` and `nuint` shall be represented by the types `System.IntPtr` and `System.UIntPtr`, respectively, `nint` and `nuint` are *not* aliases for those types. As such, not all members of the corresponding `System` types are defined for `nint` and `nuint`. Instead, the compiler shall make available additional conversions and operations for the types `System.IntPtr` and `System.UIntPtr` when used in the context of native integer types.
322+
Although `nint` and `nuint` shall be represented by the types `System.IntPtr` and `System.UIntPtr`, respectively, `nint` and `nuint` are *not* aliases for those types. As such, not all members of the corresponding `System` types are defined for `nint` and `nuint`. Instead, the compiler shall make available additional conversions, unary operators12.9) and arithmetic operators12.12) for the types `System.IntPtr` and `System.UIntPtr` when used in the context of native integer types.
323323
324-
While the implementation provides operations and conversions for `nint` and `nuint` that are appropriate for integer types, those operations and conversions are not available on the `System` type counterparts. For example,
324+
While the language provides operations and conversions for `nint` and `nuint` that are appropriate for integer types, those operations and conversions are not available on the `System` type counterparts. For example,
325325
326326
<!-- Example: {template:"code-in-main-without-using", name:"SimpleTypes3", expectedException:"RuntimeBinderException"} -->
327327
```csharp
@@ -362,14 +362,16 @@ public string ToString(string format);
362362

363363
Interfaces implemented by `System.IntPtr` and `System.UIntPtr` are implicitly included in `nint` and `nuint`, with occurrences of the underlying types replaced by the corresponding native integer types. For example, if `IntPtr` implements `ISerializable`, `IEquatable<IntPtr>`, and `IComparable<IntPtr>`, then `nint` implements `ISerializable`, `IEquatable<nint>`, and `IComparable<nint>`.
364364

365+
`typeof(nint)` is `typeof(System.IntPtr)`, and `typeof(nuint)` is `typeof(System.UIntPtr)`.
366+
367+
<!-- The following three paragraphs can be deleted for C# 10 -->
368+
365369
`nint` and `System.IntPtr`, and `nuint` and `System.UIntPtr`, are considered equivalent for overriding, hiding, and implementing, however.
366370

367371
Overloads cannot differ by `nint` and `System.IntPtr`, and `nuint` and `System.UIntPtr`, alone. However, overrides and implementations may differ by `nint` and `System.IntPtr`, or `nuint` and `System.UIntPtr`, alone.
368372

369373
Methods hide other methods that differ by `nint` and `System.IntPtr`, or `nuint` and `System.UIntPtr`, alone.
370374

371-
`typeof(nint)` is `typeof(System.IntPtr)`, and `typeof(nuint)` is `typeof(System.UIntPtr)`.
372-
373375
### 8.3.6 Integral types
374376

375377
C# supports the following integral types, with the sizes and value ranges, as shown:

0 commit comments

Comments
 (0)