當前位置: 首頁>>代碼示例>>C#>>正文


C# ListDictionary.CopyTo方法代碼示例

本文整理匯總了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");
		}
開發者ID:nlhepler,項目名稱:mono,代碼行數:32,代碼來源:ListDictionaryTest.cs

示例2: CopyTo2

 public void CopyTo2 ()
 {
         ListDictionary ld = new ListDictionary ();
         ld.CopyTo (new int[1],-1);       
 }
開發者ID:jjenki11,項目名稱:blaze-chem-rendering,代碼行數:5,代碼來源:ListDictionaryTest.cs

示例3: CopyTo1

 public void CopyTo1 ()
 {
         ListDictionary ld = new ListDictionary ();
         ld.CopyTo (null, 0);
 }
開發者ID:jjenki11,項目名稱:blaze-chem-rendering,代碼行數:5,代碼來源:ListDictionaryTest.cs

示例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;
 }
開發者ID:BGCX261,項目名稱:zhoulijinrong-svn-to-git,代碼行數:17,代碼來源:DocumentManager.cs


注:本文中的System.Collections.Specialized.ListDictionary.CopyTo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。