Skip to content

Commit 534bd16

Browse files
authored
add iformattable interface (dotnet#4617)
1 parent da03fcc commit 534bd16

File tree

2 files changed

+16
-23
lines changed

2 files changed

+16
-23
lines changed

xml/System/IntPtr.xml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,20 +86,20 @@
8686
<remarks>
8787
<format type="text/markdown"><![CDATA[
8888
89-
## Remarks
89+
## Remarks
90+
9091
The <xref:System.IntPtr> type is designed to be an integer whose size is platform-specific. That is, an instance of this type is expected to be 32-bits on 32-bit hardware and operating systems, and 64-bits on 64-bit hardware and operating systems.
9192
92-
The <xref:System.IntPtr> type can be used by languages that support pointers, and as a common means of referring to data between languages that do and do not support pointers.
93+
The <xref:System.IntPtr> type can be used by languages that support pointers and as a common means of referring to data between languages that do and do not support pointers.
9394
9495
<xref:System.IntPtr> objects can also be used to hold handles. For example, instances of <xref:System.IntPtr> are used extensively in the <xref:System.IO.FileStream?displayProperty=nameWithType> class to hold file handles.
9596
9697
The <xref:System.IntPtr> type is CLS-compliant, while the <xref:System.UIntPtr> type is not. Only the <xref:System.IntPtr> type is used in the common language runtime. The <xref:System.UIntPtr> type is provided mostly to maintain architectural symmetry with the <xref:System.IntPtr> type.
9798
98-
This type implements the <xref:System.Runtime.Serialization.ISerializable> interface.
99-
100-
99+
This type implements the <xref:System.Runtime.Serialization.ISerializable>, and, in .NET 5.0 and later, the <xref:System.IFormattable> interfaces.
101100
102-
## Examples
101+
## Examples
102+
103103
The following example uses managed pointers to reverse the characters in an array. After it initializes a <xref:System.String> object and gets its length, it does the following:
104104
105105
1. Calls the <xref:System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi%2A?displayProperty=nameWithType> method to copy the Unicode string to unmanaged memory as an ANSI (one-byte) character. The method returns an <xref:System.IntPtr> object that points to the beginning of the unmanaged string. The Visual Basic example uses this pointer directly; in the C++ and C# examples, it is cast to a pointer to a byte.
@@ -374,9 +374,7 @@
374374
## Remarks
375375
The <xref:System.IntPtr.Add%2A> method does not throw an exception if the result is too large to represent as a pointer on the specified platform. Instead, the addition operation is performed in an unchecked context.
376376
377-
Languages that do not support operator overloading or custom operators can use this method to add an offset to the value of a pointer.
378-
379-
377+
Languages that do not support operator overloading or custom operators can use this method to add an offset to the value of a pointer.
380378
381379
## Examples
382380
The following example instantiates an <xref:System.IntPtr> object that points to the beginning of a ten-element array, and then calls the <xref:System.IntPtr.Add%2A> method to iterate the elements in the array.
@@ -1532,9 +1530,7 @@
15321530
## Remarks
15331531
The <xref:System.IntPtr.Subtract%2A> method does not throw an exception if the result is too small to represent as a pointer on the specified platform. Instead, the subtraction operation is performed in an unchecked context.
15341532
1535-
Languages that do not support operator overloading or custom operators can use this method to subtract an offset from the value of a pointer.
1536-
1537-
1533+
Languages that do not support operator overloading or custom operators can use this method to subtract an offset from the value of a pointer.
15381534
15391535
## Examples
15401536
The following example instantiates an <xref:System.IntPtr> object that points to the end of a ten-element array, and then calls the <xref:System.IntPtr.Subtract%2A> method to iterate the elements in the array in reverse order.
@@ -2161,7 +2157,7 @@ This member is an explicit interface member implementation. It can be used only
21612157
[!code-vb[System.IntPtr.Zero#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.intptr.zero/vb/zero4.vb#2)]
21622158
21632159
> [!NOTE]
2164-
> Although <xref:System.IntPtr.Zero> is equivalent to `null` for Windows API functions with parameters or return values that can be either pointers or `null`, <xref:System.IntPtr.Zero> is not equivalent to `null`. Passing `null` to the `IntPtr.Zero.Equals` method always returns `false`.
2160+
> Although <xref:System.IntPtr.Zero> is equivalent to `null` for Windows API functions with parameters or return values that can be either pointers or `null`, <xref:System.IntPtr.Zero> is not equivalent to `null`. Passing `null` to the `IntPtr.Zero.Equals` method always returns `false`.
21652161
21662162
You can also test for a `null` return value from Windows API function calls that return either a pointer or a `null` by comparing the returned value with <xref:System.IntPtr.Zero?displayProperty=nameWithType>. For example, the call to the `GetWindow` function in the following example tries to retrieve the handle of a non-existent window. If it were called from unmanaged code, the function would return `null`, but when it is called from managed code, it returns <xref:System.IntPtr.Zero?displayProperty=nameWithType>.
21672163

xml/System/UIntPtr.xml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,16 @@
9090
<remarks>
9191
<format type="text/markdown"><![CDATA[
9292
93-
## Remarks
93+
## Remarks
94+
9495
The <xref:System.UIntPtr> type is designed to be an integer whose size is platform-specific. That is, an instance of this type is expected to be 32-bits on 32-bit hardware and operating systems, and 64-bits on 64-bit hardware and operating systems.
9596
9697
> [!IMPORTANT]
97-
> The <xref:System.IntPtr> type is CLS-compliant, while the <xref:System.UIntPtr> type is not. Only the <xref:System.IntPtr> type is used in the common language runtime. The <xref:System.UIntPtr> type is provided mostly to maintain architectural symmetry with the <xref:System.IntPtr> type.
98+
> The <xref:System.IntPtr> type is CLS-compliant, while the <xref:System.UIntPtr> type is not. Only the <xref:System.IntPtr> type is used in the common language runtime. The <xref:System.UIntPtr> type is provided mostly to maintain architectural symmetry with the <xref:System.IntPtr> type.
9899
99100
The <xref:System.UIntPtr> type can be used by languages that support pointers, and as a common means of referring to data between languages that do and do not support pointers. <xref:System.UIntPtr> objects can also be used to hold handles.
100101
101-
This type implements the <xref:System.Runtime.Serialization.ISerializable> interface.
102+
This type implements the <xref:System.Runtime.Serialization.ISerializable>, and, in .NET 5.0 and later, the <xref:System.IFormattable> interfaces.
102103
103104
]]></format>
104105
</remarks>
@@ -322,9 +323,7 @@
322323
## Remarks
323324
The <xref:System.IntPtr.Add%2A> method does not throw an exception if the result is too large to represent as a pointer on the specified platform. Instead, the addition operation is performed in an unchecked context.
324325
325-
Languages that do not support operator overloading or custom operators can use this method to add an offset to the value of an unsigned pointer.
326-
327-
326+
Languages that do not support operator overloading or custom operators can use this method to add an offset to the value of an unsigned pointer.
328327
329328
## Examples
330329
The following example instantiates a <xref:System.UIntPtr> object that points to the beginning of a ten-element array, and then calls the <xref:System.UIntPtr.Add%2A> method to iterate the elements in the array.
@@ -1373,9 +1372,7 @@
13731372
## Remarks
13741373
The <xref:System.IntPtr.Subtract%2A> method does not throw an exception if the result is too small to represent as a pointer on the specified platform. Instead, the subtraction operation is performed in an unchecked context.
13751374
1376-
Languages that do not support operator overloading or custom operators can use this method to subtract an offset from the value of an unsigned pointer.
1377-
1378-
1375+
Languages that do not support operator overloading or custom operators can use this method to subtract an offset from the value of an unsigned pointer.
13791376
13801377
## Examples
13811378
The following example instantiates an <xref:System.IntPtr> object that points to the end of a ten-element array, and then calls the <xref:System.IntPtr.Subtract%2A> method to iterate the elements in the array in reverse order.
@@ -1910,7 +1907,7 @@ This member is an explicit interface member implementation. It can be used only
19101907
## Remarks
19111908
The value of this field is not equivalent to `null`. Use this field to efficiently determine whether an instance of <xref:System.UIntPtr> has been set to a value other than zero.
19121909
1913-
For example, assume the variable, uip, is an instance of <xref:System.UIntPtr>. You can determine if it has been set by comparing it to the value returned by a constructor, for example: " `if uip != new UIntPtr(0)...` ". However, invoking a constructor to get an uninitialized pointer is inefficient. It is better to code either " `if uip != UIntPtr.Zero...` ", or " `if !UIntPtr.Zero.Equals(uip)...` ".
1910+
For example, assume the variable, uip, is an instance of <xref:System.UIntPtr>. You can determine if it has been set by comparing it to the value returned by a constructor, for example, `if uip != new UIntPtr(0)...`. However, invoking a constructor to get an uninitialized pointer is inefficient. It is better to code either `if uip != UIntPtr.Zero...` or `if !UIntPtr.Zero.Equals(uip)...`.
19141911
19151912
]]></format>
19161913
</remarks>

0 commit comments

Comments
 (0)