Skip to content

Commit d284151

Browse files
learn-build-service-prod[bot]Learn Build Service GitHub AppAlexGutenievveganaiZeAaronRobinsonMSFT
authored
Confirm merge from FromPublicMasterBranch to main to sync with https://github.com/MicrosoftDocs/cpp-docs (branch main) (#6756)
* Update Vectorized STL algorithm documentation to reflect the current stae (#5937) Since the last update: * ARM64 and ARM64EC vectorization was added. Mention of x64 and x86 is removed, as vectorization is now supported on any target, except deprecated `/clr:pure` and `/clr:safe` modes. * `includes` is now manually vectorized too * `replace_copy` is now manually vectorized too Also moved `find_end` to `search` / `search_n` group, where it fits better. * Update header-files-cpp.md (#5938) Clarify intent of section * Update documentation on accessing System.String characters (#5940) * Update documentation on accessing System.String characters Added important note about treating interior pointers as const and linked to unsafe code best practices. * Update docs/dotnet/how-to-access-characters-in-a-system-string.md Co-authored-by: Jan Kotas <jkotas@microsoft.com> * Apply suggestions from code review Co-authored-by: Aaron R Robinson <arobins@microsoft.com> * Apply suggestions from code review Co-authored-by: Aaron R Robinson <arobins@microsoft.com> --------- Co-authored-by: Jan Kotas <jkotas@microsoft.com> --------- Co-authored-by: learn-build-service-prod[bot] <113403604+learn-build-service-prod[bot]@users.noreply.github.com> Co-authored-by: Learn Build Service GitHub App <Learn Build Service LearnBuild@microsoft.com> Co-authored-by: Alex Guteniev <gutenev@gmail.com> Co-authored-by: veganaiZe <7102064+veganaiZe@users.noreply.github.com> Co-authored-by: Aaron R Robinson <arobins@microsoft.com> Co-authored-by: Jan Kotas <jkotas@microsoft.com>
1 parent 6eefb9f commit d284151

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

docs/dotnet/how-to-access-characters-in-a-system-string.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ helpviewer_keywords: ["characters [C++], accessing in System::String", "examples
99

1010
You can access characters of a <xref:System.String> object for high-performance calls to unmanaged functions that take `wchar_t*` strings. The method yields an interior pointer to the first character of the <xref:System.String> object. This pointer can be manipulated directly or pinned and passed to a function expecting an ordinary **`wchar_t`** string.
1111

12+
> [!IMPORTANT]
13+
> Interior pointers into <xref:System.String> objects must be treated as `const`. A <xref:System.String> object is considered immutable and changing its content can destabilize the runtime.
14+
> For more information see [Unsafe code best practices - 17. String mutations](/dotnet/standard/unsafe-code/best-practices).
15+
1216
## Examples
1317

1418
`PtrToStringChars` returns a <xref:System.Char>, which is an interior pointer (also known as a `byref`). As such, it is subject to garbage collection. You don't have to pin this pointer unless you're going to pass it to a native function.

0 commit comments

Comments
 (0)