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


C# ListDictionary.ToString方法代码示例

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


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

示例1: runTest

 public virtual bool runTest()
 {
     Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
     int iCountErrors = 0;
     int iCountTestcases = 0;
     String strLoc = "Loc_000oo";
     ListDictionary ld; 
     try
     {
         Console.WriteLine("--- default ctor ---");
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         ld = new ListDictionary();
         Console.WriteLine("1. compare to null");
         iCountTestcases++;
         if (ld == null) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001, dictionary is null after default ctor");
         } 
         Console.WriteLine("2. check Count");
         iCountTestcases++;
         if (ld.Count != 0) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002, Count = {0} after default ctor", ld.Count);
         }
         Console.WriteLine("3. check Item(some_key)");
         iCountTestcases++;
         if (ld["key"] != null) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003, Item(some_key) returned non-null after default ctor");
         }
         Console.WriteLine("4. check ToString()");
         iCountTestcases++;
         string temp = ld.ToString();
         Console.WriteLine(" ToString(): " + temp);
         if (temp.IndexOf("ListDictionary") == -1) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0004, ToString() doesn't contain \"ListDictionary\"");
         }
         Console.WriteLine("5. check returned Type");
         iCountTestcases++;
         temp = ld.GetType().ToString().Trim();
         Console.WriteLine(" GetType(): " + temp);
         if (temp.IndexOf("ListDictionary") == -1) 
         {  
             iCountErrors++;
             Console.WriteLine("Err_0005: returned type doesn't contain \"ListDictionary\"");
         }
         Console.WriteLine("6. compare returned Type of two dictionary");
         iCountTestcases++;
         string temp1 = (new ListDictionary()).GetType().ToString().Trim();
         if (String.Compare(temp, temp1) != 0) 
         {  
             iCountErrors++;
             Console.WriteLine("Err_0006: returned types of two collections differ");
         }
         Console.WriteLine("7. check Keys collection");
         iCountTestcases++;
         System.Collections.ICollection keys = ld.Keys;
         if ( keys.Count != 0) 
         {  
             iCountErrors++;
             Console.WriteLine("Err_0007: Keys contains {0} keys after default ctor", keys.Count);
         }
         Console.WriteLine("8. check Values collection");
         iCountTestcases++;
         System.Collections.ICollection values = ld.Values;
         if ( values.Count != 0) 
         {  
             iCountErrors++;
             Console.WriteLine("Err_0008: Values contains {0} items after default ctor", values.Count);
         }
         Console.WriteLine("9. Add(name, value)");
         iCountTestcases++;
         ld.Add("Name", "Value");
         if (ld.Count != 1) 
         {  
             iCountErrors++;
             Console.WriteLine("Err_0009a: Count returned {0} instead of 1", ld.Count);
         }
         if (String.Compare(ld["Name"].ToString(), "Value", false) != 0)  
         {  
             iCountErrors++;
             Console.WriteLine("Err_0009b: Item() returned unexpected value");
         }
         Console.WriteLine("10. Clear()");
         iCountTestcases++;
         ld.Clear();
         if (ld.Count != 0) 
         {  
             iCountErrors++;
             Console.WriteLine("Err_00010a: Count returned {0} instead of 0 after Clear()", ld.Count);
         }
         if (ld["Name"] != null)  
         {  
             iCountErrors++;
//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:co8682ctor.cs


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