本文整理汇总了C#中ConcurrentDictionary.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# ConcurrentDictionary.CopyTo方法的具体用法?C# ConcurrentDictionary.CopyTo怎么用?C# ConcurrentDictionary.CopyTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConcurrentDictionary
的用法示例。
在下文中一共展示了ConcurrentDictionary.CopyTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyToTest
public void CopyToTest()
{
var Test = new ConcurrentDictionary<string, int>();
var Test2 = new ConcurrentDictionary<string, int>();
Test.AddOrUpdate("Q", 4, (x, y) => 4);
Test.AddOrUpdate("Z", 2, (x, y) => 2);
Test.AddOrUpdate("C", 3, (x, y) => 3);
Test.AddOrUpdate("A", 1, (x, y) => 1);
Test.CopyTo(Test2);
string Value = "";
int Value2 = 0;
foreach (string Key in Test2.Keys.OrderBy(x => x))
{
Value += Key;
Value2 += Test2[Key];
}
Assert.Equal("ACQZ", Value);
Assert.Equal(10, Value2);
}
示例2: CopyTo_ThrowsNotImplementedException
public void CopyTo_ThrowsNotImplementedException()
{
// Arrange
ConcurrentDictionary<int, int> dictionary = new ConcurrentDictionary<int, int>();
// Act/Assert
Assert.Throws<NotImplementedException>(() => dictionary.CopyTo(new KeyValuePair<int, int>[1], 1));
}