当前位置: 首页>>代码示例>>C#>>正文


C# RepeatedField.AddRange方法代码示例

本文整理汇总了C#中RepeatedField.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# RepeatedField.AddRange方法的具体用法?C# RepeatedField.AddRange怎么用?C# RepeatedField.AddRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RepeatedField的用法示例。


在下文中一共展示了RepeatedField.AddRange方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddRange_SlowPath

 public void AddRange_SlowPath()
 {
     var list = new RepeatedField<string>();
     list.AddRange(new[] { "foo", "bar" }.Select(x => x));
     Assert.AreEqual(2, list.Count);
     Assert.AreEqual("foo", list[0]);
     Assert.AreEqual("bar", list[1]);
 }
开发者ID:ChemiCoder,项目名称:protobuf,代码行数:8,代码来源:RepeatedFieldTest.cs

示例2: AddRange_SlowPath_NullsProhibited_NullableValueType

 public void AddRange_SlowPath_NullsProhibited_NullableValueType()
 {
     var list = new RepeatedField<int?>();
     // It's okay for this to throw ArgumentNullException if necessary.
     // It's not ideal, but not awful.
     Assert.Catch<ArgumentException>(() => list.AddRange(new[] { 20, (int?)null }.Select(x => x)));
 }
开发者ID:ChemiCoder,项目名称:protobuf,代码行数:7,代码来源:RepeatedFieldTest.cs

示例3: AddRange_SlowPath_NullsProhibited_ReferenceType

 public void AddRange_SlowPath_NullsProhibited_ReferenceType()
 {
     var list = new RepeatedField<string>();
     // It's okay for this to throw ArgumentNullException if necessary.
     // It's not ideal, but not awful.
     Assert.Catch<ArgumentException>(() => list.AddRange(new[] { "foo", null }.Select(x => x)));
 }
开发者ID:ChemiCoder,项目名称:protobuf,代码行数:7,代码来源:RepeatedFieldTest.cs

示例4: AddRange_RepeatedField

 public void AddRange_RepeatedField()
 {
     var list = new RepeatedField<string> { "original" };
     list.AddRange(new RepeatedField<string> { "foo", "bar" });
     Assert.AreEqual(3, list.Count);
     Assert.AreEqual("original", list[0]);
     Assert.AreEqual("foo", list[1]);
     Assert.AreEqual("bar", list[2]);
 }
开发者ID:ChemiCoder,项目名称:protobuf,代码行数:9,代码来源:RepeatedFieldTest.cs

示例5: AddRange_AlreadyNotEmpty

 public void AddRange_AlreadyNotEmpty()
 {
     var list = new RepeatedField<int> { 1, 2, 3 };
     list.AddRange(new List<int> { 4, 5, 6 });
     CollectionAssert.AreEqual(new[] { 1, 2, 3, 4, 5, 6 }, list);
 }
开发者ID:ChemiCoder,项目名称:protobuf,代码行数:6,代码来源:RepeatedFieldTest.cs

示例6: AddRange_Optimized_NullsProhibited_NullableValueType

 public void AddRange_Optimized_NullsProhibited_NullableValueType()
 {
     // We don't just trust that a collection with a nullable element type doesn't contain nulls
     var list = new RepeatedField<int?>();
     // It's okay for this to throw ArgumentNullException if necessary.
     // It's not ideal, but not awful.
     Assert.Catch<ArgumentException>(() => list.AddRange(new List<int?> { 20, null }));
 }
开发者ID:ChemiCoder,项目名称:protobuf,代码行数:8,代码来源:RepeatedFieldTest.cs

示例7: AddRange_Optimized_NullableValueType

 public void AddRange_Optimized_NullableValueType()
 {
     var list = new RepeatedField<int?>();
     list.AddRange(new List<int?> { 20, 30 });
     Assert.AreEqual(2, list.Count);
     Assert.AreEqual((int?) 20, list[0]);
     Assert.AreEqual((int?) 30, list[1]);
 }
开发者ID:ChemiCoder,项目名称:protobuf,代码行数:8,代码来源:RepeatedFieldTest.cs

示例8: AddRange_Optimized_ReferenceType

 public void AddRange_Optimized_ReferenceType()
 {
     var list = new RepeatedField<string>();
     list.AddRange(new List<string> { "foo", "bar" });
     Assert.AreEqual(2, list.Count);
     Assert.AreEqual("foo", list[0]);
     Assert.AreEqual("bar", list[1]);
 }
开发者ID:ChemiCoder,项目名称:protobuf,代码行数:8,代码来源:RepeatedFieldTest.cs


注:本文中的RepeatedField.AddRange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。