Browse Source

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

C#: Allow readonly view of byteString's data with ByteString.Memory property
Jan Tattermusch 5 years ago
parent
commit
440a156e1c
1 changed files with 6 additions and 0 deletions
  1. 6 0
      csharp/src/Google.Protobuf/ByteString.cs

+ 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>