Эх сурвалжийг харах

Merge pull request #6904 from erikma/dev/erikmav/byteStringMemory

C#: Allow readonly view of byteString's data with ByteString.Memory property
Jan Tattermusch 5 жил өмнө
parent
commit
440a156e1c

+ 6 - 0
csharp/src/Google.Protobuf/ByteString.cs

@@ -116,6 +116,12 @@ namespace Google.Protobuf
         /// No data is copied so this is the most efficient way of accessing.
         /// </summary>
         public ReadOnlySpan<byte> Span => new ReadOnlySpan<byte>(bytes);
+
+        /// <summary>
+        /// Provides read-only access to the data of this <see cref="ByteString"/>.
+        /// No data is copied so this is the most efficient way of accessing.
+        /// </summary>
+        public ReadOnlyMemory<byte> Memory => new ReadOnlyMemory<byte>(bytes);
 #endif
 
         /// <summary>