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


C# StringDictionary.ToString方法代码示例

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


在下文中一共展示了StringDictionary.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";
     StringDictionary sd; 
     try
     {
         Console.WriteLine("--- default ctor ---");
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         sd = new StringDictionary();
         Console.WriteLine("1. compare to null");
         iCountTestcases++;
         if (sd == null) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001, collection is null after default ctor");
         } 
         Console.WriteLine("2. check Count");
         iCountTestcases++;
         if (sd.Count != 0) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002, Count = {0} after default ctor", sd.Count);
         }
         Console.WriteLine("3. check ContainsValue()");
         iCountTestcases++;
         if (sd.ContainsValue("string")) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003, ContainsValue() returned true after default ctor");
         }
         Console.WriteLine("4. check ContainsKey()");
         iCountTestcases++;
         if (sd.ContainsKey("string")) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0004, ContainsKey() returned true after default ctor");
         }
         Console.WriteLine("5. check ToString()");
         iCountTestcases++;
         string temp = sd.ToString();
         Console.WriteLine(" ToString(): " + temp);
         if (temp.IndexOf("StringDictionary") == -1) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0005, ToString() doesn't contain \"StringDictionary\"");
         }
         Console.WriteLine("6. check returned Type");
         iCountTestcases++;
         temp = sd.GetType().ToString().Trim();
         Console.WriteLine(" GetType(): " + temp);
         if (temp.IndexOf("StringDictionary") == -1) 
         {  
             iCountErrors++;
             Console.WriteLine("Err_0006: returned type doesn't contain \"StringDictionary\"");
         }
         Console.WriteLine("7. compare returned Type of two Dictionaries");
         iCountTestcases++;
         string temp1 = (new StringDictionary()).GetType().ToString().Trim();
         if (String.Compare(temp, temp1) != 0) 
         {  
             iCountErrors++;
             Console.WriteLine("Err_0007: returned types of two collections differ");
         }
         Console.WriteLine("8. check IsSynchronized");
         iCountTestcases++;
         Console.WriteLine(" IsSynchronized: " + sd.IsSynchronized);
         if (sd.IsSynchronized) 
         {  
             iCountErrors++;
             Console.WriteLine("Err_0008: IsSynchronized returned {0}", sd.IsSynchronized);
         }
         Console.WriteLine("9. add item and verify");
         iCountTestcases++;
         sd.Add("key", "value");
         iCountTestcases++;
         if (sd.Count != 1) 
         {  
             iCountErrors++;
             Console.WriteLine("Err_0009a: Count returned {0}", sd.Count);
         }
         iCountTestcases++;
         if ( !sd.ContainsKey("key") ) 
         {  
             iCountErrors++;
             Console.WriteLine("Err_0009b: ContainsKey() returned false");
         } 
         iCountTestcases++;
         if ( !sd.ContainsValue("value") ) 
         {  
             iCountErrors++;
             Console.WriteLine("Err_0009c: ContainsValue() returned false");
         }
     } 
     catch (Exception exc_general ) 
     {
         ++iCountErrors;
//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:co8754ctor.cs


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