本文整理汇总了C#中Sequence.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# Sequence.AddRange方法的具体用法?C# Sequence.AddRange怎么用?C# Sequence.AddRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sequence
的用法示例。
在下文中一共展示了Sequence.AddRange方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SequenceTestSerialize
public void SequenceTestSerialize()
{
Sequence<int> before = new Sequence<int>(3);
before.AddRange( new[] {1,2});
before.Add(3);
before.Add(4);
Assert.Equal(4, before[0]);
Assert.Equal(3, before[1]);
Assert.Equal(2, before[2]);
Assert.Equal(3, before.Capacity);
Assert.Equal(4, before.CountOfAllObservedItems);
//JsonSerializerSettings serializerSettings = new JsonSerializerSettings();
//serializerSettings.Converters.Add(new SequenceConverter());
string serialized = JsonConvert.SerializeObject(before);
Sequence<int> after = JsonConvert.DeserializeObject<Sequence<int>>(serialized);
Assert.Equal(4, after[0]);
Assert.Equal(3, after[1]);
Assert.Equal(2,after[2]);
Assert.Equal(3, after.Capacity);
Assert.Equal(4, after.CountOfAllObservedItems);
Assert.Equal(before, after);
}
示例2: SequenceTestToList
public void SequenceTestToList()
{
Sequence<int> s = new Sequence<int>(5);
s.AddRange(new[] { 1, 2, 3 });
List<int> asList = s.ToList();
Assert.Equal(1, asList[0]);
Assert.Equal(2, asList[1]);
Assert.Equal(3, asList[2]);
}