aboutsummaryrefslogtreecommitdiff
path: root/csharp/ProtocolBuffers/ByteString.cs
diff options
context:
space:
mode:
Diffstat (limited to 'csharp/ProtocolBuffers/ByteString.cs')
-rw-r--r--csharp/ProtocolBuffers/ByteString.cs12
1 files changed, 11 insertions, 1 deletions
diff --git a/csharp/ProtocolBuffers/ByteString.cs b/csharp/ProtocolBuffers/ByteString.cs
index 94eb45e3..7c644f9a 100644
--- a/csharp/ProtocolBuffers/ByteString.cs
+++ b/csharp/ProtocolBuffers/ByteString.cs
@@ -15,13 +15,15 @@
// limitations under the License.
using System.Text;
using System;
+using System.Collections.Generic;
+using System.Collections;
namespace Google.ProtocolBuffers {
/// <summary>
/// Immutable array of bytes.
/// TODO(jonskeet): Implement the common collection interfaces?
/// </summary>
- public sealed class ByteString {
+ public sealed class ByteString : IEnumerable<byte> {
private static readonly ByteString empty = new ByteString(new byte[0]);
@@ -105,6 +107,14 @@ namespace Google.ProtocolBuffers {
return ToString(Encoding.UTF8);
}
+ public IEnumerator<byte> GetEnumerator() {
+ return ((IEnumerable<byte>) bytes).GetEnumerator();
+ }
+
+ IEnumerator IEnumerable.GetEnumerator() {
+ return GetEnumerator();
+ }
+
/// <summary>
/// Creates a CodedInputStream from this ByteString's data.
/// </summary>