diff --git a/src/System.Private.CoreLib/shared/System/String.cs b/src/System.Private.CoreLib/shared/System/String.cs index 10f75225c00d..177d5e1f17b1 100644 --- a/src/System.Private.CoreLib/shared/System/String.cs +++ b/src/System.Private.CoreLib/shared/System/String.cs @@ -472,6 +472,13 @@ public static bool IsNullOrWhiteSpace(string value) return true; } + /// + /// Returns a reference to the first element of the String. If the string is null, an access will throw a NullReferenceException. + /// + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + [NonVersionable] + public ref readonly char GetPinnableReference() => ref _firstChar; + internal ref char GetRawStringData() => ref _firstChar; // Helper for encodings so they can talk to our buffer directly