aboutsummaryrefslogtreecommitdiff
path: root/csharp/ProtocolBuffers/ByteString.cs
diff options
context:
space:
mode:
authorJon Skeet <skeet@pobox.com>2008-08-14 20:35:20 +0100
committerJon Skeet <skeet@pobox.com>2008-08-14 20:35:20 +0100
commit1353315dede3e22266df73fca8dd421119597e46 (patch)
treecc05bb6735c7225d53524807a6fe9a374248e10e /csharp/ProtocolBuffers/ByteString.cs
parentb84310e1101af3c442e102f4c9ed03f3eff105fb (diff)
downloadprotobuf-1353315dede3e22266df73fca8dd421119597e46.tar.gz
protobuf-1353315dede3e22266df73fca8dd421119597e46.tar.bz2
protobuf-1353315dede3e22266df73fca8dd421119597e46.zip
Implemented TextFormatter
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>