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


C# StringCollection.Add方法代码示例

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


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

示例1: Explode

 public static StringCollection Explode(string path)
 {
     int num2;
     StringCollection strings = new StringCollection();
     int startIndex = 0;
 Label_0008:
     num2 = path.IndexOf(SeparatorChar, startIndex);
     if (num2 >= 0)
     {
         if (startIndex == num2)
         {
             strings.Add(Separator);
             startIndex = num2 + 1;
         }
         else
         {
             strings.Add(path.Substring(startIndex, num2 - startIndex));
             startIndex = num2;
         }
         goto Label_0008;
     }
     if (startIndex < path.Length)
     {
         strings.Add(path.Substring(startIndex));
     }
     return strings;
 }
开发者ID:Nathan-M-Ross,项目名称:i360gm,代码行数:27,代码来源:PathUtil.cs

示例2: CleanWordHtml

        private static string CleanWordHtml(string html)
        {
            StringCollection sc = new StringCollection();

            // get rid of unnecessary tag spans (comments and title)
            sc.Add(@"<!--(\w|\W)+?-->");
            sc.Add(@"<title>(\w|\W)+?</title>");

            // Get rid of classes and styles
            sc.Add(@"\s?class=\w+");
            sc.Add(@"\s+style='[^']+'");

            // Get rid of unnecessary tags
            sc.Add(
                @"<(meta|link|/?o:|/?style|/?div|/?st\d|/?head|/?html|body|/?body|/?span|!\[)[^>]*?>");

            // Get rid of empty paragraph tags
            sc.Add(@"(<[^>]+>)+&nbsp;(</\w+>)+");

            // remove bizarre v: element attached to <img> tag
            sc.Add(@"\s+v:\w+=""[^""]+""");

            // remove extra lines
            sc.Add(@"(\n\r){2,}");
            foreach (string s in sc)
            {
                html = Regex.Replace(html, s, string.Empty, RegexOptions.IgnoreCase);
            }

            return html;
        }
开发者ID:krishnakant,项目名称:CampusWebstore,代码行数:31,代码来源:CrossSiteAttackUtil.cs

示例3: ParsePoLine

    /// <summary>
    /// a line in a po translation file starts with either msgid or msgstr, and can cover several lines.
    /// the text is in quotes.
    /// </summary>
    public static string ParsePoLine(StreamReader sr, ref string ALine, out StringCollection AOriginalLines)
    {
        AOriginalLines = new StringCollection();
        AOriginalLines.Add(ALine);

        string messageId = String.Empty;
        StringHelper.GetNextCSV(ref ALine, " ");
        string quotedMessage = StringHelper.GetNextCSV(ref ALine, " ");

        if (quotedMessage.StartsWith("\""))
        {
            quotedMessage = quotedMessage.Substring(1, quotedMessage.Length - 2);
        }

        messageId += quotedMessage;

        ALine = sr.ReadLine();

        while (ALine.StartsWith("\""))
        {
            AOriginalLines.Add(ALine);
            messageId += ALine.Substring(1, ALine.Length - 2);
            ALine = sr.ReadLine();
        }

        return messageId;
    }
开发者ID:js1987,项目名称:openpetragit,代码行数:31,代码来源:ParsePoFile.cs

示例4: ClipboardFetchFilesItemTest

        public void ClipboardFetchFilesItemTest()
        {
            string file1 = Path.GetTempFileName();
            string file2 = Path.GetTempFileName();

            var dummyFiles = new StringCollection();

            dummyFiles.Add(file1);
            dummyFiles.Add(file2);

            Clipboard.Clear();
            Clipboard.SetFileDropList(dummyFiles);

            StringCollection copiedList = Clipboard.GetFileDropList();
            Assert.AreEqual(copiedList.Count, dummyFiles.Count);

            var factory = new ClipboardFileFactory();

            var item = factory.CreateNewClipboardItem(IntPtr.Zero) as ClipboardFileCollection;
            Assert.IsNotNull(item);

            Assert.AreEqual(item.Paths.Count(), 2);

            List<string> localList = item.Paths.ToList();

            for (int i = 0; i < localList.Count; i++)
            {
                Assert.AreEqual(localList[i], dummyFiles[i]);
            }

            File.Delete(file1);
            File.Delete(file2);
        }
开发者ID:Zargess,项目名称:Shapeshifter-old,代码行数:33,代码来源:ClipboardTest.cs

示例5: PeekrPop2006

        ///<summary>
        ///</summary>
        public PeekrPop2006()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            // Source Queues
            mqServerName.Items.Clear();
            queueName.Items.Clear();

            // Target Queues
            targetServerCombo.Items.Clear();
            targetQueueCombo.Items.Clear();
            targetQueue2.Items.Clear();

            // Source Machine Names
            StringCollection sc = new StringCollection ();
            sc.Add ("VDC3APP0006");
            sc.Add ("localhost");

            foreach (string s in sc)
            {
                mqServerName.Items.Add (s);
                targetServerCombo.Items.Add (s);
            }
        }
开发者ID:raveller,项目名称:raveller,代码行数:29,代码来源:PeekrPop2006.cs

示例6: ParseMultiValue

        //
        // <



        private static string[] ParseMultiValue(string value) {
            StringCollection tempStringCollection = new StringCollection();

            bool inquote = false;
            int chIndex = 0;
            char[] vp = new char[value.Length];
            string singleValue;

            for (int i = 0; i < value.Length; i++) {
                if (value[i] == '\"') {
                    inquote = !inquote;
                }
                else if ((value[i] == ',') && !inquote) {
                    singleValue = new string(vp, 0, chIndex);
                    tempStringCollection.Add(singleValue.Trim());
                    chIndex = 0;
                    continue;
                }
                vp[chIndex++] = value[i];
            }

            //
            // Now add the last of the header values to the stringtable.
            //

            if (chIndex != 0) {
                singleValue = new string(vp, 0, chIndex);
                tempStringCollection.Add(singleValue.Trim());
            }

            string[] stringArray = new string[tempStringCollection.Count];
            tempStringCollection.CopyTo(stringArray, 0) ;
            return stringArray;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:39,代码来源:_HeaderInfoTable.cs

示例7: readBrainFile

        //read brain file from disc
        protected StringCollection readBrainFile()
        {
            StringCollection sc = new StringCollection();
            if(File.Exists(filePath))
            {
               	FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
               	StreamReader rs = new StreamReader(fs);
               	string line;
               	while ((line = rs.ReadLine()) != null)
                {
               		sc.Add(line);
               	}
               	rs.Close();
               	fs.Close();
            }
            else
            {
                MessageBox.Show("No mind file found, creating new one");
                FileStream cs = File.Create(filePath);
                cs.Close();
                FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
               	StreamReader rs = new StreamReader(fs);
               	string line;
               	while ((line = rs.ReadLine()) != null)
                {
               		sc.Add(line);
               	}
               	rs.Close();
               	fs.Close();

            }
            return sc;
        }
开发者ID:sanyaade-g2g-repos,项目名称:prelude-csharp,代码行数:34,代码来源:Brain.cs

示例8: generate

        /// <summary>
        /// Generate statistics file
        /// </summary>
        /// <returns></returns>
        public StringCollection generate()
        {                                
            #region delete all older files (of the same type) for this questionnaire to clean temp-Directory
            try
            {
                foreach (string file in Directory.GetFiles(pathtotempdir, "RFG_report_statistic_*"))
                {
                    File.Delete(file);
                }                
            }
            catch (Exception ex)
            {
                string dummy = ex.ToString();
            }
            #endregion
            
            int statistics_records = -1;
            List<string> files_names = new List<string>();
            statistics_records = ReportingFacade.Format(from, until, ordering, row_number, pathtotempdir,Company_Code, ref files_names);                   

            StringCollection retvals = new StringCollection();
            retvals.Add(statistics_records.ToString());
            foreach (String file in files_names)
                retvals.Add(file);
            return retvals;
        }
开发者ID:amalapannuru,项目名称:RFC,代码行数:30,代码来源:process_statistics.cs

示例9: DeleteUsers

 public void DeleteUsers()
 {
     StringCollection usersToDelete = new StringCollection();
     usersToDelete.Add("OtisCurry");
     usersToDelete.Add("Scurry");
     int userWasDeleted = awRestCalls.DeleteUsers(usersToDelete);
 }
开发者ID:scotcurry,项目名称:AWRestAPI,代码行数:7,代码来源:AWRestAPITests.cs

示例10: GetColumnNames

        public static StringCollection GetColumnNames(string filePath, string workSheet, bool headers, int? count = null)
        {
            using (OleDbConnection excelConnection = new OleDbConnection(GetConnectionString(filePath, headers)))
            {
                StringCollection columnNames = new StringCollection();
                excelConnection.Open();
                String[] restriction = { null, null, workSheet, null };
                DataTable dtColumns = excelConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, restriction);

                if (dtColumns == null)
                    throw new Exception("no columns found!");
                else
                {
                    if(count == null || count >= dtColumns.Rows.Count)
                     foreach (DataRow row in dtColumns.Rows)
                        columnNames.Add(row["COLUMN_NAME"].ToString());
                    else
                    {
                        for (int i = 0; i < count; i++)
                            columnNames.Add(dtColumns.Rows[i]["COLUMN_NAME"].ToString());
                    }

                }

                excelConnection.Close();
                return columnNames;
            }
        }
开发者ID:sky8273,项目名称:Timing,代码行数:28,代码来源:ExcelHelper.cs

示例11: SplitUpperCase

        public static string[] SplitUpperCase(this string source)
        {
            if (source == null)
                return new string[] {}; //Return empty array.

            if (source.Length == 0)
                return new[] {""};

            var words = new StringCollection();
            int wordStartIndex = 0;

            char[] letters = source.ToCharArray();
            char previousChar = char.MinValue;
            // Skip the first letter. we don't care what case it is.
            for (int i = 1; i < letters.Length; i++)
            {
                if (char.IsUpper(letters[i]) && !char.IsWhiteSpace(previousChar))
                {
                    //Grab everything before the current index.
                    words.Add(new String(letters, wordStartIndex, i - wordStartIndex));
                    wordStartIndex = i;
                }
                previousChar = letters[i];
            }
            //We need to have the last word.
            words.Add(new String(letters, wordStartIndex, letters.Length - wordStartIndex));

            //Copy to a string array.
            var wordArray = new string[words.Count];
            words.CopyTo(wordArray, 0);
            return wordArray;
        }
开发者ID:CamiCasus,项目名称:FiguraManager,代码行数:32,代码来源:StringExtensions.cs

示例12: AddElementToStringCollection

        private static void AddElementToStringCollection(IElement element, ref StringCollection stringCollection,
            int currentLevel, string prefix, bool isLast)
        {
            if (currentLevel == 0)
                stringCollection.Add(element.ToString());
            else
            {
                stringCollection.Add(prefix + "|_" + element);

                if (isLast && element.ChildrenCount == 0)
                    stringCollection.Add(prefix);

                if (isLast)
                    prefix += "   ";
                else
                    prefix += "|  ";
            }

            for (int childIndex = 0; childIndex < element.ChildrenCount; childIndex++)
            {
                IElement child = element[childIndex];
                AddElementToStringCollection(child, ref stringCollection, currentLevel + 1, prefix,
                    childIndex == element.ChildrenCount - 1);
            }
        }
开发者ID:gilind,项目名称:workshop,代码行数:25,代码来源:StringConverter.cs

示例13: SplitCamelCase

        /// <summary>
        /// http://weblogs.asp.net/jgalloway/archive/2005/09/27/426087.aspx
        /// </summary>
        public static List<string> SplitCamelCase(this string source)
        {
            if (source == null)
                return new List<string> { }; //Return empty array.

            if (source.Length == 0)
                return new List<string> { "" };

            StringCollection words = new StringCollection();
            int wordStartIndex = 0;

            char[] letters = source.ToCharArray();
            // Skip the first letter. we don't care what case it is.
            for (int i = 1; i < letters.Length; i++)
            {
                if (char.IsUpper(letters[i]))
                {
                    //Grab everything before the current index.
                    words.Add(new String(letters, wordStartIndex, i - wordStartIndex));
                    wordStartIndex = i;
                }
            }

            //We need to have the last word.
            words.Add(new String(letters, wordStartIndex, letters.Length - wordStartIndex));

            //Copy to a string array.
            string[] wordArray = new string[words.Count];
            words.CopyTo(wordArray, 0);

            List<string> stringList = new List<string>();
            stringList.AddRange(wordArray);
            return stringList;
        }
开发者ID:neutmute,项目名称:TailTool,代码行数:37,代码来源:StringExtensions.cs

示例14: ParseMultiValue

 private static string[] ParseMultiValue(string value)
 {
     StringCollection strings = new StringCollection();
     bool flag = false;
     int length = 0;
     char[] chArray = new char[value.Length];
     for (int i = 0; i < value.Length; i++)
     {
         if (value[i] == '"')
         {
             flag = !flag;
         }
         else if ((value[i] == ',') && !flag)
         {
             string str = new string(chArray, 0, length);
             strings.Add(str.Trim());
             length = 0;
             continue;
         }
         chArray[length++] = value[i];
     }
     if (length != 0)
     {
         strings.Add(new string(chArray, 0, length).Trim());
     }
     string[] array = new string[strings.Count];
     strings.CopyTo(array, 0);
     return array;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:29,代码来源:HeaderInfoTable.cs

示例15: ToStringCollection

 public static StringCollection ToStringCollection(Dictionary<string, string> dic)
 {
     var sc = new StringCollection();
     foreach (var d in dic)
     {
         sc.Add(d.Key);
         sc.Add(d.Value);
     }
     return sc;
 }
开发者ID:kaotul,项目名称:autotrade,代码行数:10,代码来源:SettingUtils.cs


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