本文整理汇总了C#中System.Collections.Specialized.ListDictionary.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# ListDictionary.CopyTo方法的具体用法?C# ListDictionary.CopyTo怎么用?C# ListDictionary.CopyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Specialized.ListDictionary
的用法示例。
在下文中一共展示了ListDictionary.CopyTo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BasicTests
private void BasicTests (ListDictionary ld)
{
Assert.AreEqual (0, ld.Count, "Count");
Assert.IsFalse (ld.IsFixedSize, "IsFixedSize");
Assert.IsFalse (ld.IsReadOnly, "IsReadOnly");
Assert.IsFalse (ld.IsSynchronized, "IsSynchronized");
Assert.AreEqual (0, ld.Keys.Count, "Keys");
Assert.AreEqual (0, ld.Values.Count, "Values");
Assert.IsNotNull (ld.SyncRoot, "SyncRoot");
Assert.IsNotNull (ld.GetEnumerator (), "GetEnumerator");
Assert.IsNotNull ((ld as IEnumerable).GetEnumerator (), "IEnumerable.GetEnumerator");
ld.Add ("a", "1");
Assert.AreEqual (1, ld.Count, "Count-1");
Assert.IsTrue (ld.Contains ("a"), "Contains(a)");
Assert.IsFalse (ld.Contains ("1"), "Contains(1)");
ld.Add ("b", null);
Assert.AreEqual (2, ld.Count, "Count-2");
Assert.IsNull (ld["b"], "this[b]");
DictionaryEntry[] entries = new DictionaryEntry[2];
ld.CopyTo (entries, 0);
ld["b"] = "2";
Assert.AreEqual ("2", ld["b"], "this[b]2");
ld.Remove ("b");
Assert.AreEqual (1, ld.Count, "Count-3");
ld.Clear ();
Assert.AreEqual (0, ld.Count, "Count-4");
}
示例2: CopyTo2
public void CopyTo2 ()
{
ListDictionary ld = new ListDictionary ();
ld.CopyTo (new int[1],-1);
}
示例3: CopyTo1
public void CopyTo1 ()
{
ListDictionary ld = new ListDictionary ();
ld.CopyTo (null, 0);
}
示例4: ConvertToDE
/// <summary>
///
/// </summary>
/// <param name="entries"></param>
/// <returns></returns>
public static DictionaryEntry[] ConvertToDE(DictionaryEntry[] entries)
{
//用ListDictionary主要是為了稍後可以直接CopyTo轉DictionaryEntry[]
ListDictionary list = new ListDictionary();
foreach (DictionaryEntry entry in entries)
{
list.Add(entry.Key, entry.Value);
}
DictionaryEntry[] result = new DictionaryEntry[list.Count];
list.CopyTo(result, 0);
return result;
}