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


C# NameValueCollection.GetType方法代码示例

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


在下文中一共展示了NameValueCollection.GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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";
     NameValueCollection nvc; 
     try
     {
         Console.WriteLine("--- default ctor ---");
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         nvc = new NameValueCollection();
         Console.WriteLine("1. compare to null");
         iCountTestcases++;
         if (nvc == null) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001, collection is null after default ctor");
         } 
         Console.WriteLine("2. check Count");
         iCountTestcases++;
         if (nvc.Count != 0) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002, Count = {0} after default ctor", nvc.Count);
         }
         Console.WriteLine("3. check Get(some_key)");
         iCountTestcases++;
         if (nvc.Get("key") != null) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003, Get(some_key) returned non-null after default ctor");
         }
         Console.WriteLine("4. check ToString()");
         iCountTestcases++;
         string temp = nvc.ToString();
         Console.WriteLine(" ToString(): " + temp);
         if (temp.IndexOf("NameValueCollection") == -1) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0004, ToString() doesn't contain \"NameValueCollection\"");
         }
         Console.WriteLine("5. check returned Type");
         iCountTestcases++;
         temp = nvc.GetType().ToString().Trim();
         Console.WriteLine(" GetType(): " + temp);
         if (temp.IndexOf("NameValueCollection") == -1) 
         {  
             iCountErrors++;
             Console.WriteLine("Err_0005: returned type doesn't contain \"NameValueCollection\"");
         }
         Console.WriteLine("6. compare returned Type of two collection");
         iCountTestcases++;
         string temp1 = (new NameValueCollection()).GetType().ToString().Trim();
         if (String.Compare(temp, temp1) != 0) 
         {  
             iCountErrors++;
             Console.WriteLine("Err_0006: returned types of two collections differ");
         }
         Console.WriteLine("7. check AllKeys array");
         iCountTestcases++;
         string [] keys = nvc.AllKeys;
         if ( keys.Length != 0) 
         {  
             iCountErrors++;
             Console.WriteLine("Err_0007: AllKeys contains {0} keys after default ctor", keys.Length);
         }
         Console.WriteLine("8. check Item(some_key)");
         iCountTestcases++;
         if (nvc["key"] != null) 
         {  
             iCountErrors++;
             Console.WriteLine("Err_0008: Item(some_key) returned non-null after default ctor");
         }
         Console.WriteLine("9. Add(name, value)");
         iCountTestcases++;
         nvc.Add("Name", "Value");
         if (nvc.Count != 1) 
         {  
             iCountErrors++;
             Console.WriteLine("Err_0009a: Count returned {0} instead of 1", nvc.Count);
         }
         if (String.Compare(nvc["Name"], "Value", false) != 0)  
         {  
             iCountErrors++;
             Console.WriteLine("Err_0009b: Item() returned unexpected value");
         }
         Console.WriteLine("10. Clear()");
         iCountTestcases++;
         nvc.Clear();
         if (nvc.Count != 0) 
         {  
             iCountErrors++;
             Console.WriteLine("Err_00010a: Count returned {0} instead of 0 after Clear()", nvc.Count);
         }
         if (nvc["Name"] != null)  
         {  
             iCountErrors++;
             Console.WriteLine("Err_00010b: Item() returned non-null value after Clear()");
//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:co8718ctor.cs

示例2: 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";
     NameValueCollection nvc; 
     NameValueCollection nvc1;         
     string [] values = 
     {
         "",
         " ",
         "a",
         "aa",
         "tExt",
         "     SPaces",
         "1",
         "$%^#",
         "2222222222222222222222222",
         System.DateTime.Today.ToString(),
         Int32.MaxValue.ToString()
     };
     string [] names = 
     {
         "zero",
         "oNe",
         " ",
         "",
         "aA",
         "1",
         System.DateTime.Today.ToString(),
         "$%^#",
         Int32.MaxValue.ToString(),
         "     spaces",
         "2222222222222222222222222"
     };
     try
     {
         Console.WriteLine("--- default ctor ---");
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         nvc1 = new NameValueCollection();
         Console.WriteLine("1. Create from another empty collection");
         nvc = new NameValueCollection(nvc1);
         Console.WriteLine("1.1 compare to null");
         iCountTestcases++;
         if (nvc == null) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001.1, collection is null");
         } 
         Console.WriteLine("1.2. check Count");
         iCountTestcases++;
         if (nvc.Count != 0) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001.2, Count = {0} ", nvc.Count);
         }
         Console.WriteLine("1.3. check Get(some_key)");
         iCountTestcases++;
         if (nvc.Get("key") != null) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001.3, Get(some_key) returned non-null after default ctor");
         }
         Console.WriteLine("1.4. check ToString()");
         iCountTestcases++;
         string temp = nvc.ToString();
         Console.WriteLine(" ToString(): " + temp);
         if (temp.IndexOf("NameValueCollection") == -1) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001.4, ToString() doesn't contain \"NameValueCollection\"");
         }
         Console.WriteLine("1.5. check returned Type");
         iCountTestcases++;
         temp = nvc.GetType().ToString().Trim();
         Console.WriteLine(" GetType(): " + temp);
         if (temp.IndexOf("NameValueCollection") == -1) 
         {  
             iCountErrors++;
             Console.WriteLine("Err_0001.5: returned type doesn't contain \"NameValueCollection\"");
         }
         Console.WriteLine("1.6. compare returned Type of two collection");
         iCountTestcases++;
         string temp1 = (new NameValueCollection()).GetType().ToString().Trim();
         if (String.Compare(temp, temp1) != 0) 
         {  
             iCountErrors++;
             Console.WriteLine("Err_0001.6: returned types of two collections differ");
         }
         Console.WriteLine("1.7. check AllKeys array");
         iCountTestcases++;
         string [] keys = nvc.AllKeys;
         if ( keys.Length != 0) 
         {  
             iCountErrors++;
             Console.WriteLine("Err_0001.7: AllKeys contains {0} keys after default ctor", keys.Length);
         }
         Console.WriteLine("1.8. check Item(some_key)");
//.........这里部分代码省略.........
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:101,代码来源:co8719ctor_nvc.cs


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