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


C# StringCollection.Clear方法代码示例

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


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

示例1: getCatList

        private void getCatList(int number,ref StringCollection catList,out CategoryTypeCollection categories)
        {
            bool isSuccess;
            string message;

            catList.Clear();
            //get a leaf category
            isSuccess=CategoryHelper.GetCISSupportLeafCategory(number,out categories,this.apiContext,out message);
            Assert.IsTrue(isSuccess,message);
            for(int i=0;i<number;i++)
            {
                //add to catList
                catList.Add(categories[i].CategoryID);
            }
        }
开发者ID:fudder,项目名称:cs493,代码行数:15,代码来源:T_120_GetCategorySpecificsLibrary.cs

示例2: CountTest

 public static void CountTest(StringCollection collection, string[] data)
 {
     Assert.Equal(data.Length, collection.Count);
     collection.Clear();
     Assert.Equal(0, collection.Count);
     collection.Add("one");
     Assert.Equal(1, collection.Count);
     collection.AddRange(data);
     Assert.Equal(1 + data.Length, collection.Count);
 }
开发者ID:ESgarbi,项目名称:corefx,代码行数:10,代码来源:StringCollectionTests.cs

示例3: ClearTest

 public static void ClearTest(StringCollection collection, string[] data)
 {
     Assert.Equal(data.Length, collection.Count);
     collection.Clear();
     Assert.Equal(0, collection.Count);
 }
开发者ID:ESgarbi,项目名称:corefx,代码行数:6,代码来源:StringCollectionTests.cs

示例4: runTest

 public virtual bool runTest()
 {
     Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
     int iCountErrors = 0;
     int iCountTestcases = 0;
     IntlStrings intl;
     String strLoc = "Loc_000oo";
     StringCollection sc; 
     string [] values = 
     {
         "",
         " ",
         "a",
         "aa",
         "text",
         "     spaces",
         "1",
         "$%^#",
         "2222222222222222222222222",
         System.DateTime.Today.ToString(),
         Int32.MaxValue.ToString()
     };
     try
     {
         intl = new IntlStrings(); 
         Console.WriteLine("--- create collection ---");
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         sc = new StringCollection();
         Console.WriteLine("1. Count on empty collection");
         iCountTestcases++;
         if (sc.Count != 0) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001, returned {0} for empty collection", sc.Count);
         }
         Console.WriteLine("2. add simple strings and verify Count");
         strLoc = "Loc_002oo"; 
         iCountTestcases++;
         sc.Clear();
         sc.AddRange(values);
         if (sc.Count != values.Length) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002a, count is {0} instead of {1}", sc.Count, values.Length);
         } 
         iCountTestcases++;
         sc.Clear();
         sc.AddRange(values);
         if (sc.Count != values.Length) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002b, count is {0} instead of {1}", sc.Count, values.Length);
         } 
         Console.WriteLine("3. add intl strings and verify Count");
         strLoc = "Loc_003oo"; 
         string [] intlValues = new string [values.Length];
         for (int i = 0; i < values.Length; i++) 
         {
             string val = intl.GetString(MAX_LEN, true, true, true);
             while (Array.IndexOf(intlValues, val) != -1 )
                 val = intl.GetString(MAX_LEN, true, true, true);
             intlValues[i] = val;
         } 
         iCountTestcases++;
         sc.Clear();
         sc.AddRange(intlValues);
         if ( sc.Count != intlValues.Length ) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003a, count is {0} instead of {1}", sc.Count, intlValues.Length);
         } 
         iCountTestcases++;
         sc.Clear();
         sc.AddRange(intlValues);
         if ( sc.Count != intlValues.Length ) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003b, count is {0} instead of {1}", sc.Count, intlValues.Length);
         } 
     } 
     catch (Exception exc_general ) 
     {
         ++iCountErrors;
         Console.WriteLine (s_strTFAbbrev + " : Error Err_general!  strLoc=="+ strLoc +", exc_general==\n"+exc_general.ToString());
     }
     if ( iCountErrors == 0 )
     {
         Console.WriteLine( "Pass.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
         return true;
     }
     else
     {
         Console.WriteLine("Fail!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
         return false;
     }
 }
开发者ID:ArildF,项目名称:masters,代码行数:97,代码来源:co8748get_count.cs

示例5: runTest

 public virtual bool runTest()
 {
     Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
     int iCountErrors = 0;
     int iCountTestcases = 0;
     IntlStrings intl;
     String strLoc = "Loc_000oo";
     StringCollection sc; 
     string [] values = 
     {
         "",
         " ",
         "a",
         "aa",
         "text",
         "     spaces",
         "1",
         "$%^#",
         "2222222222222222222222222",
         System.DateTime.Today.ToString(),
         Int32.MaxValue.ToString()
     };
     int cnt = 0;            
     try
     {
         intl = new IntlStrings(); 
         Console.WriteLine("--- create collection ---");
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         sc = new StringCollection();
         Console.WriteLine("1. Check for empty collection");
         for (int i = 0; i < values.Length; i++) 
         {
             iCountTestcases++;
             if (sc.IndexOf(values[i]) != -1) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0001_{0}, returned {1} for empty collection", i, sc.IndexOf(values[i]));
             }
         } 
         Console.WriteLine("2. add simple strings and verify IndexOf()");
         strLoc = "Loc_002oo"; 
         iCountTestcases++;
         cnt = sc.Count;
         sc.AddRange(values);
         if (sc.Count != values.Length) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002a, count is {0} instead of {1}", sc.Count, values.Length);
         } 
         for (int i = 0; i < values.Length; i++) 
         {
             iCountTestcases++;
             if (sc.IndexOf(values[i]) != i) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0002_{0}b, IndexOf returned {1} instead of {0}", i, sc.IndexOf(values[i]));
             } 
         }
         Console.WriteLine("3. add intl strings and verify IndexOf()");
         strLoc = "Loc_003oo"; 
         string [] intlValues = new string [values.Length];
         for (int i = 0; i < values.Length; i++) 
         {
             string val = intl.GetString(MAX_LEN, true, true, true);
             while (Array.IndexOf(intlValues, val) != -1 )
                 val = intl.GetString(MAX_LEN, true, true, true);
             intlValues[i] = val;
         } 
         int len = values.Length;
         Boolean caseInsensitive = false;
         for (int i = 0; i < len; i++) 
         {
             if(intlValues[i].Length!=0 && intlValues[i].ToLower()==intlValues[i].ToUpper())
                 caseInsensitive = true;
         }
         iCountTestcases++;
         cnt = sc.Count;
         sc.AddRange(intlValues);
         if ( sc.Count != (cnt + intlValues.Length) ) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003a, count is {0} instead of {1}", sc.Count, cnt + intlValues.Length);
         } 
         for (int i = 0; i < intlValues.Length; i++) 
         {
             iCountTestcases++;
             if (sc.IndexOf(intlValues[i]) != values.Length + i) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0003_{0}b, IndexOf returned {1} instead of {2}", i, sc.IndexOf(intlValues[i]), values.Length + i);
             } 
         }
         Console.WriteLine("4. duplicate strings ");
         strLoc = "Loc_004oo"; 
         iCountTestcases++;
         sc.Clear();
         string intlStr = intlValues[0];
         sc.Add(intlStr);        
         sc.AddRange(values);
//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:co8744indexof_str.cs

示例6: getCIS

        /// <summary>
        /// Specify custom item specify
        /// </summary>
        /// <returns></returns>
        private NameValueListTypeCollection getCIS()
        {
            NameValueListTypeCollection list = new NameValueListTypeCollection();
            StringCollection tmp=new StringCollection();

            NameValueListType nameValue1=new NameValueListType();
            nameValue1.Name="test specifics(add name1)";
            tmp.Add("test specifics(add value1)");
            nameValue1.Value=tmp;

            NameValueListType nameValue2=new NameValueListType();
            nameValue2.Name="test specifics(add name2)";
            tmp.Clear();
            tmp.Add("test specifics(add value2)");
            nameValue2.Value=tmp;

            list.Add(nameValue1);
            list.Add(nameValue2);

            return list;
        }
开发者ID:fudder,项目名称:cs493,代码行数:25,代码来源:T_010_AddItemLibrary.cs

示例7: runTest

 public virtual bool runTest()
 {
     Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
     int iCountErrors = 0;
     int iCountTestcases = 0;
     IntlStrings intl;
     String strLoc = "Loc_000oo";
     StringCollection sc; 
     string [] values = 
     {
         "",
         " ",
         "a",
         "aa",
         "text",
         "     spaces",
         "1",
         "$%^#",
         "2222222222222222222222222",
         System.DateTime.Today.ToString(),
         Int32.MaxValue.ToString()
     };
     try
     {
         intl = new IntlStrings(); 
         Console.WriteLine("--- create collection ---");
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         sc = new StringCollection();
         Console.WriteLine("1. RemoveAt() from empty collection");
         iCountTestcases++;
         if (sc.Count > 0)
             sc.Clear();
         try 
         {
             sc.RemoveAt(0);
             iCountErrors++;
             Console.WriteLine("Err_0001_{0}a, no exception");
         }
         catch (ArgumentOutOfRangeException ex) 
         {
             Console.WriteLine(" expected exception: " + ex.Message);
         }    
         catch (Exception e) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001_{0}b, unexpected exception: " + e.ToString());
         }    
         Console.WriteLine("2. RemoveAt() on filled collection");
         strLoc = "Loc_002oo"; 
         Console.WriteLine(" - at the beginning");
         iCountTestcases++;
         sc.Clear();
         sc.AddRange(values);
         if (sc.Count != values.Length) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002a, count is {0} instead of {1}", sc.Count, values.Length);
         } 
         iCountTestcases++;
         sc.RemoveAt(0);
         if (sc.Count != values.Length - 1) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002b, Count returned {0} instead of {1}", sc.Count, values.Length - 1);
         } 
         iCountTestcases++;
         if (sc.Contains(values[0])) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002c, removed wrong item");
         } 
         for (int i = 0; i < values.Length; i++) 
         { 
             iCountTestcases++;
             if (sc.IndexOf(values[i]) != i-1) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0002_{0}d, IndexOf returned {1} instead of {2}", i, sc.IndexOf(values[i]), i-1);
             } 
         }
         Console.WriteLine(" - at the end");
         iCountTestcases++;
         sc.Clear();
         sc.AddRange(values);
         if (sc.Count != values.Length) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002e, count is {0} instead of {1}", sc.Count, values.Length);
         } 
         iCountTestcases++;
         sc.RemoveAt(values.Length-1);
         if (sc.Count != values.Length - 1) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002f, Count returned {0} instead of {1}", sc.Count, values.Length - 1);
         } 
         iCountTestcases++;
         if (sc.Contains(values[values.Length - 1])) 
         {
//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:co8747removeat_int.cs

示例8: 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";
     StringCollection sc; 
     string [] values = 
     {
         "",
         " ",
         "a",
         "aa",
         "text",
         "     spaces",
         "1",
         "$%^#",
         "2222222222222222222222222",
         System.DateTime.Today.ToString(),
         Int32.MaxValue.ToString()
     };
     try
     {
         Console.WriteLine("--- create collection ---");
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         sc = new StringCollection();
         Console.WriteLine("1. IsSynchronized on empty collection");
         iCountTestcases++;
         if (sc.IsSynchronized) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001, returned true for empty collection");
         }
         Console.WriteLine("2. IsSynchronized for filled collection");
         strLoc = "Loc_002oo"; 
         iCountTestcases++;
         sc.Clear();
         sc.AddRange(values);
         if (sc.Count != values.Length) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002a, count is {0} instead of {1}", sc.Count, values.Length);
         } 
         iCountTestcases++;
         if (sc.IsSynchronized) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002b, returned true for filled collection");
         } 
     } 
     catch (Exception exc_general ) 
     {
         ++iCountErrors;
         Console.WriteLine (s_strTFAbbrev + " : Error Err_general!  strLoc=="+ strLoc +", exc_general==\n"+exc_general.ToString());
     }
     if ( iCountErrors == 0 )
     {
         Console.WriteLine( "Pass.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
         return true;
     }
     else
     {
         Console.WriteLine("Fail!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
         return false;
     }
 }
开发者ID:ArildF,项目名称:masters,代码行数:67,代码来源:co8750get_issynchronized.cs

示例9: getStringsFromBuffer

	private void getStringsFromBuffer(Byte[] Buffer, int bufLen, StringCollection Strings)
	{
		Strings.Clear();
		if (bufLen != 0)
		{
			int start = 0;
			for (int i = 0; i < bufLen; i++)
			{
				if ((Buffer[i] == 0) && ((i - start) > 0))
				{
					String s = Encoding.GetEncoding(0).GetString(Buffer, start, i - start);
					Strings.Add(s);
					start = i + 1;
				}
			}
		}
	}
开发者ID:gfxmode,项目名称:LIB,代码行数:17,代码来源:IniHandler.cs

示例10: runTest

 public virtual bool runTest()
 {
     Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
     int iCountErrors = 0;
     int iCountTestcases = 0;
     IntlStrings intl;
     String strLoc = "Loc_000oo";
     StringCollection sc; 
     string itm;         
     string [] values = 
     {
         "",
         " ",
         "a",
         "aa",
         "text",
         "     spaces",
         "1",
         "$%^#",
         "2222222222222222222222222",
         System.DateTime.Today.ToString(),
         Int32.MaxValue.ToString()
     };
     try
     {
         intl = new IntlStrings(); 
         Console.WriteLine("--- create collection ---");
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         sc = new StringCollection();
         Console.WriteLine("1. get Item from empty collection");
         Console.WriteLine(" (-1)th");
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         try 
         {
             itm = sc[-1];
             iCountErrors++;
             Console.WriteLine("Err_0001a, no exception");
         }
         catch (ArgumentOutOfRangeException ex) 
         {
             Console.WriteLine("  expected exception: " + ex.Message);
         }
         catch (Exception e) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001b, unexpected exception: {0}", e.ToString());
         }
         Console.WriteLine(" 0th");
         iCountTestcases++;
         try 
         {
             itm = sc[0];
             iCountErrors++;
             Console.WriteLine("Err_0001c, no exception");
         }
         catch (ArgumentOutOfRangeException ex) 
         {
             Console.WriteLine("  expected exception: " + ex.Message);
         }
         catch (Exception e) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001d, unexpected exception: {0}", e.ToString());
         }
         Console.WriteLine("2. Get Item on collection with simple strings");
         strLoc = "Loc_002oo";
         sc.Clear(); 
         iCountTestcases++;
         sc.AddRange(values);
         if (sc.Count != values.Length) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002a, count is {0} instead of {1}", sc.Count, values.Length);
         } 
         for (int i = 0; i < values.Length; i++) 
         {
             iCountTestcases++;
             if (String.Compare(sc[i], values[i], false) != 0) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0002_{0}b, returned {1} instead of {2}", i, sc[i], values[i]);
             } 
         }
         Console.WriteLine("3. get Item on collection with intl strings");
         strLoc = "Loc_003oo"; 
         string [] intlValues = new string [values.Length];
         for (int i = 0; i < values.Length; i++) 
         {
             string val = intl.GetString(MAX_LEN, true, true, true);
             while (Array.IndexOf(intlValues, val) != -1 )
                 val = intl.GetString(MAX_LEN, true, true, true);
             intlValues[i] = val;
         } 
         int len = values.Length;
         Boolean caseInsensitive = false;
         for (int i = 0; i < len; i++) 
         {
             if(intlValues[i].Length!=0 && intlValues[i].ToLower()==intlValues[i].ToUpper())
//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:co8751get_item.cs

示例11: runTest

 public virtual bool runTest()
 {
     Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
     int iCountErrors = 0;
     int iCountTestcases = 0;
     IntlStrings intl;
     String strLoc = "Loc_000oo";
     StringCollection sc; 
     string itm;         
     string [] values = 
     {
         "",
         " ",
         "a",
         "aa",
         "text",
         "     spaces",
         "1",
         "$%^#",
         "2222222222222222222222222",
         System.DateTime.Today.ToString(),
         Int32.MaxValue.ToString()
     };
     try
     {
         intl = new IntlStrings(); 
         Console.WriteLine("--- create collection ---");
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         sc = new StringCollection();
         Console.WriteLine("1. set Item on empty collection");
         Console.WriteLine(" (-1)th");
         strLoc = "Loc_001oo"; 
         itm = intl.GetString(MAX_LEN, true, true, true);
         iCountTestcases++;
         try 
         {
             sc[-1] = itm;
             iCountErrors++;
             Console.WriteLine("Err_0001a, no exception");
         }
         catch (ArgumentOutOfRangeException ex) 
         {
             Console.WriteLine("  expected exception: " + ex.Message);
         }
         catch (Exception e) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001b, unexpected exception: {0}", e.ToString());
         }
         Console.WriteLine(" 0th to string");
         iCountTestcases++;
         try 
         {
             sc[0] = itm;
             iCountErrors++;
             Console.WriteLine("Err_0001c, no exception");
         }
         catch (ArgumentOutOfRangeException ex) 
         {
             Console.WriteLine("  expected exception: " + ex.Message);
         }
         catch (Exception e) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001d, unexpected exception: {0}", e.ToString());
         }
         Console.WriteLine(" 0th to null");
         iCountTestcases++;
         try 
         {
             sc[0] = null;
             iCountErrors++;
             Console.WriteLine("Err_0001e, no exception");
         }
         catch (ArgumentOutOfRangeException ex) 
         {
             Console.WriteLine("  expected exception: " + ex.Message);
         }
         catch (Exception e) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001f, unexpected exception: {0}", e.ToString());
         }
         Console.WriteLine("2. set Item on collection with simple strings");
         strLoc = "Loc_002oo";
         sc.Clear(); 
         iCountTestcases++;
         sc.AddRange(values);
         int cnt = values.Length;
         if (sc.Count != cnt) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002a, count is {0} instead of {1}", sc.Count, cnt);
         } 
         for (int i = 0; i < cnt; i++) 
         {
             iCountTestcases++;
             sc[i] = values[cnt-i-1];
             if (String.Compare(sc[i], values[cnt-i-1], false) != 0) 
//.........这里部分代码省略.........
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:101,代码来源:co8753set_item.cs

示例12: runTest

 public virtual bool runTest()
 {
     Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
     int iCountErrors = 0;
     int iCountTestcases = 0;
     IntlStrings intl;
     String strLoc = "Loc_000oo";
     StringCollection sc; 
     string [] values = 
     {
         "",
         " ",
         "a",
         "aa",
         "text",
         "     spaces",
         "1",
         "$%^#",
         "2222222222222222222222222",
         System.DateTime.Today.ToString(),
         Int32.MaxValue.ToString()
     };
     string[] destination;
     int cnt = 0;            
     try
     {
         intl = new IntlStrings(); 
         Console.WriteLine("--- create collection ---");
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         sc = new StringCollection();
         Console.WriteLine("1. Copy empty collection into empty array");
         iCountTestcases++;
         destination = new string[values.Length];
         for (int i = 0; i < values.Length; i++) 
         {
             destination[i] = "";
         }
         sc.CopyTo(destination, 0);
         if( destination.Length != values.Length) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001a, altered array after copying empty collection");
         } 
         if (destination.Length == values.Length) 
         {
             for (int i = 0; i < values.Length; i++) 
             {
                 iCountTestcases++;
                 if (String.Compare(destination[i], "", false) != 0) 
                 {
                     iCountErrors++;
                     Console.WriteLine("Err_0001_{0}b, item = \"{1}\" insteead of \"{2}\" after copying empty collection", i, destination[i], "");
                 }
             } 
         }
         Console.WriteLine("2. Copy empty collection into non-empty array");
         iCountTestcases++;
         destination = values;
         sc.CopyTo(destination, 0);
         if( destination.Length != values.Length) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002a, altered array after copying empty collection");
         } 
         if (destination.Length == values.Length) 
         {
             for (int i = 0; i < values.Length; i++) 
             {
                 iCountTestcases++;
                 if (String.Compare(destination[i], values[i], false) != 0) 
                 {
                     iCountErrors++;
                     Console.WriteLine("Err_0002_{0}b, altered item {0} after copying empty collection", i);
                 }
             } 
         }
         Console.WriteLine("3. add simple strings and CopyTo([], 0)");
         strLoc = "Loc_003oo"; 
         iCountTestcases++;
         cnt = sc.Count;
         sc.AddRange(values);
         if (sc.Count != values.Length) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003a, count is {0} instead of {1}", sc.Count, values.Length);
         } 
         destination = new string[values.Length];
         sc.CopyTo(destination, 0);
         for (int i = 0; i < values.Length; i++) 
         {
             iCountTestcases++;
             if ( String.Compare(sc[i], destination[i], false) != 0 ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0003_{0}b, copied \"{1}\" instead of \"{2}\"", i, destination[i], sc[i]);
             } 
         }
         Console.WriteLine("4. add simple strings and CopyTo([], {0})", values.Length);
         sc.Clear();
//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:co8742copyto_stra_int.cs

示例13: initData

    // input Entry protection/validation data
    private void initData()
    {
      // Forces validation.
      GridWeb1.ForceValidation = true;

      string path = Server.MapPath("~");
      path = path.Substring(0, path.LastIndexOf("\\"));
      string fileName = path + "\\File\\Input.xls";

      // Imports from a excel file.
      GridWeb1.ImportExcelFile(fileName);

      GridWorksheetCollection sheets = GridWeb1.WorkSheets;

      // Sets cell validation.
      GridValidationCollection gridValidationCollection = sheets[0].Validations;

      // Regular expression.
      GridValidation C5 = gridValidationCollection.Add();
      C5.AddACell("C5");
      //C5.Operator = OperatorType.BETWEEN;
      C5.ValidationType = GridValidationType.CustomExpression;
      C5.RegEx = @"\d{6}";

      // Number.
      GridValidation C6 = gridValidationCollection.Add();
      C6.AddACell("C6");
      C6.ValidationType = GridValidationType.Decimal;

      // Integer.
      GridValidation C7 = gridValidationCollection.Add();
      C7.AddACell("C7");
      C7.ValidationType = GridValidationType.WholeNumber;

      // Date.
      GridValidation C8 = gridValidationCollection.Add();
      C8.AddACell("C8");
      C8.ValidationType = GridValidationType.Date;

      // DateTime
      GridValidation C9 = gridValidationCollection.Add();
      C9.AddACell("C9");
      C9.ValidationType = GridValidationType.DateTime;

      // List.
      GridValidation C10 = gridValidationCollection.Add();
      C10.AddACell("C10");
      C10.ValidationType = GridValidationType.List;
      StringCollection value = new StringCollection();
      value.Add("Fortran");
      value.Add("Pascal");
      value.Add("C++");
      value.Add("Visual Basic");
      value.Add("Java");
      value.Add("C#");
      C10.ValueList = value;
      value.Clear();

      // DropDownList.
      GridValidation C11 = gridValidationCollection.Add();
      C11.AddACell("C11");
      C11.ValidationType = GridValidationType.DropDownList;
      value.Add("Bachelor");
      value.Add("Master");
      value.Add("Doctor");
      C11.ValueList = value;

      // FreeList
      GridValidation C12 = gridValidationCollection.Add();
      C12.AddACell("C12");
      C12.ValidationType = GridValidationType.FreeList;
      value.Add("US");
      value.Add("Britain");
      value.Add("France");
      C12.ValueList = value;

      // Custom function
      GridValidation C13 = gridValidationCollection.Add();
      C13.AddACell("C13");
      C13.ValidationType = GridValidationType.CustomFunction;
      C13.ClientValidationFunction = "myvalidation1";

      // CheckBox
      GridValidation C14 = gridValidationCollection.Add();
      C14.AddACell("C14");
      C14.ValidationType = GridValidationType.CheckBox;
    }
开发者ID:assadvirgo,项目名称:Aspose_Cells_NET,代码行数:88,代码来源:DataValidation.aspx.cs

示例14: UpdateIds

  private bool UpdateIds(StringCollection ids, DataTable table, UpdateMode mode)
  {
    bool updated = false;

    if (mode == UpdateMode.New && ids.Count > 0)
    {
      ids.Clear();
      updated = true;
    }

    foreach (DataRow row in table.Rows)
    {
      if (!row.IsNull(0))
      {
        string value = row[0].ToString();

        if (mode == UpdateMode.Remove)
        {
          if (ids.IndexOf(value) >= 0)
          {
            ids.Remove(value);
            updated = true;
          }
        }
        else
        {
          if (mode == UpdateMode.Add)
          {
            if (ids.IndexOf(value) < 0)
            {
              ids.Add(value);
              updated = true;
            }
          }
          else
          {
            ids.Add(value);
            updated = true;
          }
        }
      }
    }

    return updated;
  }
开发者ID:ClaireBrill,项目名称:GPV,代码行数:45,代码来源:SelectionHandler.cs

示例15: runTest

 public virtual bool runTest()
 {
     Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
     int iCountErrors = 0;
     int iCountTestcases = 0;
     IntlStrings intl;
     String strLoc = "Loc_000oo";
     StringCollection sc; 
     string [] values = 
     {
         "",
         " ",
         "a",
         "aa",
         "text",
         "     spaces",
         "1",
         "$%^#",
         "2222222222222222222222222",
         System.DateTime.Today.ToString(),
         Int32.MaxValue.ToString()
     };
     int cnt = 0;            
     try
     {
         intl = new IntlStrings(); 
         Console.WriteLine("--- create collection ---");
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         sc = new StringCollection();
         Console.WriteLine("1. Remove() from empty collection");
         for (int i = 0; i < values.Length; i++) 
         {
             iCountTestcases++;
             sc.Remove(values[i]);
             if (sc.Count != 0) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0001_{0}, Remove changed Count for empty collection", i);
             }
         } 
         Console.WriteLine("2. add simple strings and test Remove()");
         strLoc = "Loc_002oo"; 
         iCountTestcases++;
         sc.Clear();
         sc.AddRange(values);
         if (sc.Count != values.Length) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002a, count is {0} instead of {1}", sc.Count, values.Length);
         } 
         for (int i = 0; i < values.Length; i++) 
         {
             iCountTestcases++;
             if (!sc.Contains(values[i])) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0002_{0}b, doesn't contain {0} item", i);
             }
             cnt = sc.Count; 
             iCountTestcases++;
             sc.Remove(values[i]);
             if (sc.Count != cnt - 1) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0002_{0}c, didn't remove anything", i);
             } 
             if (sc.Contains(values[i])) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0002_{0}d, removed wrong item", i);
             } 
         }
         Console.WriteLine("3. add intl strings and test Remove()");
         strLoc = "Loc_003oo"; 
         string [] intlValues = new string [values.Length];
         for (int i = 0; i < values.Length; i++) 
         {
             string val = intl.GetString(MAX_LEN, true, true, true);
             while (Array.IndexOf(intlValues, val) != -1 )
                 val = intl.GetString(MAX_LEN, true, true, true);
             intlValues[i] = val;
         } 
         int len = values.Length;
         Boolean caseInsensitive = false;
         for (int i = 0; i < len; i++) 
         {
             if(intlValues[i].Length!=0 && intlValues[i].ToLower()==intlValues[i].ToUpper())
                 caseInsensitive = true;
         }
         iCountTestcases++;
         sc.Clear();
         sc.AddRange(intlValues);
         if ( sc.Count != intlValues.Length ) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003a, count is {0} instead of {1}", sc.Count, intlValues.Length);
         } 
         for (int i = 0; i < intlValues.Length; i++) 
         {
//.........这里部分代码省略.........
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:101,代码来源:co8746remove_str.cs


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