diff options
author | Jon Skeet <jonskeet@google.com> | 2015-08-10 08:47:07 +0100 |
---|---|---|
committer | Jon Skeet <jonskeet@google.com> | 2015-08-10 08:47:07 +0100 |
commit | 5be01ee65b987ef17e6418fbff5f161ed0f5cc87 (patch) | |
tree | 63f29c339c4752a7bcde80d3286e54c44c39a3e0 /csharp/src/Google.Protobuf/Collections | |
parent | 3f45d7c11e200184cfc09fb92efe25a63df1eef1 (diff) | |
download | protobuf-5be01ee65b987ef17e6418fbff5f161ed0f5cc87.tar.gz protobuf-5be01ee65b987ef17e6418fbff5f161ed0f5cc87.tar.bz2 protobuf-5be01ee65b987ef17e6418fbff5f161ed0f5cc87.zip |
Implement ICollection.CopyTo (using Array) for MapField views.
Diffstat (limited to 'csharp/src/Google.Protobuf/Collections')
-rw-r--r-- | csharp/src/Google.Protobuf/Collections/MapField.cs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/csharp/src/Google.Protobuf/Collections/MapField.cs b/csharp/src/Google.Protobuf/Collections/MapField.cs index 6dcdc100..004ff54b 100644 --- a/csharp/src/Google.Protobuf/Collections/MapField.cs +++ b/csharp/src/Google.Protobuf/Collections/MapField.cs @@ -735,7 +735,18 @@ namespace Google.Protobuf.Collections public void CopyTo(Array array, int index) { - throw new NotImplementedException(); + if (index < 0) + { + throw new ArgumentOutOfRangeException("arrayIndex"); + } + if (index + Count >= array.Length) + { + throw new ArgumentException("Not enough space in the array", "array"); + } + foreach (var item in this) + { + array.SetValue(item, index++); + } } } } |