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


C# StringCollection.CopyTo方法代码示例

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


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

示例1: ParseStringLines

        public static string[] ParseStringLines(string text, string commentIndicator = "#")
        {
            string[] stringLines = text.Split('\n');
            StringCollection stringCollection = new StringCollection();

            foreach (string line in stringLines)
            {
                string newLine = line.Trim();

                if (line.Contains(commentIndicator))
                {
                    string[] splitLine = line.Split(new[] { commentIndicator }, StringSplitOptions.None);
                    newLine = splitLine[0];
                }

                if (newLine.Trim().Length > 0 && validateTunnelString.IsMatch(newLine.Trim()))
                {
                    stringCollection.Add(newLine.Trim());
                }
            }

            string[] returnValue = new string[stringCollection.Count];

            stringCollection.CopyTo(returnValue, 0);

            return returnValue;
        }
开发者ID:tk-s,项目名称:BitCollectors.PlinkService,代码行数:27,代码来源:StringHelper.cs

示例2: ILDocument

    // We represent the ILasm document as a set of lines. This makes it easier to manipulate it
    // (particularly to inject snippets)

    // Create a new ildocument for the given module.
    public ILDocument(string pathModule)
    {
      // ILDasm the file to produce a textual IL file.
      //   /linenum  tells ildasm to preserve line-number information. This is needed so that we don't lose
      // the source-info when we round-trip the il.

      var pathTempIl = Path.GetTempFileName();

      // We need to invoke ildasm, which is in the sdk. 
      var pathIldasm = Program.SdkDir + "ildasm.exe";

      // We'd like to use File.Exists to make sure ildasm is available, but that function appears broken.
      // It doesn't allow spaces in the filenam, even if quoted. Perhaps just a beta 1 bug.
      
      Util.Run(pathIldasm, "\"" + pathModule + "\" /linenum /text /nobar /out=\"" + pathTempIl + "\"");


      // Now read the temporary file into a string list.
      var temp = new StringCollection();
      using (TextReader reader = new StreamReader(new FileStream(pathTempIl, FileMode.Open)))
      {
        string line;
        while ((line = reader.ReadLine()) != null) {
          // Remove .maxstack since the inline IL will very likely increase stack size.
          if (line.Trim().StartsWith(".maxstack"))
            line = "// removed .maxstack declaration";

          temp.Add(line);
        }
      }
      Lines = new string[temp.Count];
      temp.CopyTo(Lines, 0);
    }
开发者ID:damageboy,项目名称:daemaged.inlineil,代码行数:37,代码来源:ILDocument.cs

示例3: 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

示例4: Page_Load

		protected void Page_Load(object sender, EventArgs e)
		{
			// Initialise data table to hold test results
			m_results.Columns.Add("test");
			m_results.Columns.Add("result");
            m_results.Columns.Add("time");
			m_results.Columns.Add("message");
			m_results.Columns.Add("class");

			// Initialise controls
			lblResult.Text = "";
			ltlStats.Text = "";

			// Initialise NUnit
			CoreExtensions.Host.InitializeService();

			// Find tests in current assembly
			TestPackage package = new TestPackage(Assembly.GetExecutingAssembly().Location);
			m_testSuite = new TestSuiteBuilder().Build(package);

			if (!IsPostBack)
			{
				// Display category filters
				StringCollection coll = new StringCollection();
				GetCategories((TestSuite)m_testSuite, coll);
				string[] cats = new string[coll.Count];
				coll.CopyTo(cats, 0);
				Array.Sort(cats);
				cblCategories.DataSource = cats;
				cblCategories.DataBind();
			}
		}
开发者ID:KerwinMa,项目名称:WeBlog,代码行数:32,代码来源:Test.aspx.cs

示例5: 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

示例6: ReadFile

        string[,] ReadFile(string fileName)
        {
            try {
                var sc = new StringCollection ();
                var fs = new FileStream (fileName, FileMode.Open, FileAccess.ReadWrite);
                var sr = new StreamReader (fs);

                // Read file into a string collection
                int noBytesRead = 0;
                string oneLine;
                while ((oneLine = sr.ReadLine()) != null) {
                    noBytesRead += oneLine.Length;
                    sc.Add (oneLine);
                }
                sr.Close ();

                string[] sArray = new string[sc.Count];
                sc.CopyTo (sArray, 0);

                char[] cSplitter = { ' ', ',', ':', '\t' };
                string[] sArray1 = sArray [0].Split (cSplitter);
                string[,] sArray2 = new string[sArray1.Length, sc.Count];

                for (int i = 0; i < sc.Count; i++) {
                    sArray1 = sArray [sc.Count - 1 - i].Split (cSplitter);
                    for (int j = 0; j < sArray1.Length; j++) {
                        sArray2 [j, i] = sArray1 [j];
                    }
                }
                return sArray2;
            } catch (Exception) {
                return null;
            }
        }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:34,代码来源:TextFileReader.cs

示例7: GetFilesMostDeep

        /// http://jeanne.wankuma.com/tips/csharp/directory/getfilesmostdeep.html
        /// ---------------------------------------------------------------------------------------
        /// <summary>
        ///     指定した検索パターンに一致するファイルを最下層まで検索しすべて返します。</summary>
        /// <param name="stRootPath">
        ///     検索を開始する最上層のディレクトリへのパス。</param>
        /// <param name="stPattern">
        ///     パス内のファイル名と対応させる検索文字列。</param>
        /// <returns>
        ///     検索パターンに一致したすべてのファイルパス。</returns>
        /// ---------------------------------------------------------------------------------------
        public static string[] GetFilesMostDeep(string stRootPath, string stPattern)
        {
            // ファイルリスト取得開始をデバッグ出力
            Debug.Print(DateTime.Now + " Started to get files recursivery.");

            StringCollection hStringCollection = new StringCollection();

            // このディレクトリ内のすべてのファイルを検索する
            foreach (string stFilePath in Directory.GetFiles(stRootPath, stPattern))
            {
                hStringCollection.Add(stFilePath);
                Debug.Print(DateTime.Now + " Found image file, Filename = " + stFilePath);
            }

            // このディレクトリ内のすべてのサブディレクトリを検索する (再帰)
            foreach (string stDirPath in Directory.GetDirectories(stRootPath))
            {
                string[] stFilePathes = GetFilesMostDeep(stDirPath, stPattern);

                // 条件に合致したファイルがあった場合は、ArrayList に加える
                if (stFilePathes != null)
                {
                    hStringCollection.AddRange(stFilePathes);
                }
            }

            // StringCollection を 1 次元の String 配列にして返す
            string[] stReturns = new string[hStringCollection.Count];
            hStringCollection.CopyTo(stReturns, 0);

            // ファイルリスト取得終了をデバッグ出力
            Debug.Print(DateTime.Now + " Finished to get files recursivery.");

            return stReturns;
        }
开发者ID:f97one,项目名称:PictureImporter,代码行数:46,代码来源:MainForm.cs

示例8: 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

示例9: GetTokens

 internal IEnumerable<FlagTokens> GetTokens(string[] args)
 {
     StringCollection rest = new StringCollection();
     for (int i = 0; i < args.Length; i++)
     {
         var arg = args[i];
         if (arg.StartsWith("/"))
         {
             FlagTokens tok = new FlagTokens();
             tok.flag = arg;
             tok.args = null;
             int flagArgsStart = arg.IndexOf(':');
             if (flagArgsStart > 0)
             {
                 tok.flag = arg.Substring(0, flagArgsStart);
                 tok.args = arg.Substring(flagArgsStart+1).Split(';');
             }
             yield return tok;
         }
         else
         {
             rest.Add(arg);
         }
     }
     if (rest.Count > 0)
     {
         FlagTokens tok = new FlagTokens();
         tok.flag = null;
         tok.args = new string[rest.Count];
         rest.CopyTo(tok.args, 0);
         yield return tok;
     }
     yield break;
 }
开发者ID:sharmaar,项目名称:csmanage,代码行数:34,代码来源:ParseArgs.cs

示例10: 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

示例11: CollectionToArray

        public static String[] CollectionToArray(StringCollection Collection)
        {
            String[] destination = new String[Collection.Count];

            Collection.CopyTo(destination, 0);

            return destination;
        }
开发者ID:MetalMynds,项目名称:FlatGlass,代码行数:8,代码来源:StringHelper.cs

示例12: Clone

 /// <summary>
 /// Creates a shallow copy of the specified <see cref="StringCollection" />.
 /// </summary>
 /// <param name="stringCollection">The <see cref="StringCollection" /> that should be copied.</param>
 /// <returns>
 /// A shallow copy of the specified <see cref="StringCollection" />.
 /// </returns>
 public static StringCollection Clone(StringCollection stringCollection)
 {
     string[] strings = new string[stringCollection.Count];
     stringCollection.CopyTo(strings, 0);
     StringCollection clone = new StringCollection();
     clone.AddRange(strings);
     return clone;
 }
开发者ID:smaclell,项目名称:NAnt,代码行数:15,代码来源:StringUtils.cs

示例13: ToArray

        private string[] ToArray(StringCollection list, string[] defaultValue)
        {
            if(list == null)
                return defaultValue;

            string[] array = new string[list.Count];
            list.CopyTo(array, 0);
            return array;
        }
开发者ID:spmason,项目名称:n2cms,代码行数:9,代码来源:PermissionElement.cs

示例14: RecordingPlanViewModel

 /// <summary>
 /// Initializes a RecordingPlanModel form a RecordingConfig object and a list of strings with the basic movements
 /// Moreover, the RecordingPLanModel will subscribe to the events generated by the RecordingConfig object
 /// To update the view when required
 /// </summary>
 /// <param name="recordingConfig"></param>
 /// <param name="basicMovements"></param>
 public RecordingPlanViewModel(RecordingConfig recordingConfig, StringCollection basicMovements)
 {
     _recordingConfig = recordingConfig;
     recordingConfig.PropertyChanged += recordingConfig_PropertyChanged;
     _basicMovements = new string[basicMovements.Count];
     basicMovements.CopyTo(_basicMovements, 0);
     placeholderBitmap = Convert((Bitmap)Properties.Resources.ResourceManager.GetObject("nofoto"));
     completedBitmap = Convert((Bitmap)Properties.Resources.ResourceManager.GetObject("ok"));
     SetSelectedItem(-1);
 }
开发者ID:mgcarmueja,项目名称:MPTCE,代码行数:17,代码来源:RecordingPlanViewModel.cs

示例15: RelativePathTo

        /// <summary>
        /// Creates a relative path from one file or folder to another.
        /// </summary>
        /// <param name="fromDirectory">Contains the directory that defines the start of the relative path.</param>
        /// <param name="toPath">Contains the path that defines the endpoint of the relative path.</param>
        /// <returns>The relative path from the start directory to the end path.</returns>
        /// <exception cref="ArgumentNullException"></exception>
        public static string RelativePathTo(string fromDirectory, string toPath)
        {
            if (fromDirectory == null)
                throw new ArgumentNullException("fromDirectory");

            if (toPath == null)
                throw new ArgumentNullException("toPath");

            bool isRooted = Path.IsPathRooted(fromDirectory) && Path.IsPathRooted(toPath);
            if (isRooted)
            {
                bool isDifferentRoot = string.Compare(Path.GetPathRoot(fromDirectory),
                                                     Path.GetPathRoot(toPath), true) != 0;
                if (isDifferentRoot)
                    return toPath;                          
            }                
            
            StringCollection relativePath = new StringCollection();
            string[] fromDirectories = fromDirectory.Split(Path.DirectorySeparatorChar);
            string[] toDirectories = toPath.Split(Path.DirectorySeparatorChar);

            int length = Math.Min(fromDirectories.Length, toDirectories.Length);
            int lastCommonRoot = -1;

            // find common root
            for (int x = 0; x < length; x++)
            {
                if (string.Compare(fromDirectories[x], toDirectories[x], true) != 0)
                    break;

                lastCommonRoot = x;
            }
            if (lastCommonRoot == -1)
                return toPath;
            
            // add relative folders in from path
            for (int x = lastCommonRoot + 1; x < fromDirectories.Length; x++)
                if (fromDirectories[x].Length > 0)
                    relativePath.Add("..");

            // add to folders to path
            for (int x = lastCommonRoot + 1; x < toDirectories.Length; x++)
                relativePath.Add(toDirectories[x]);

            // create relative path
            string[] relativeParts = new string[relativePath.Count];
            relativePath.CopyTo(relativeParts, 0);

            string newPath = string.Join(Path.DirectorySeparatorChar.ToString(), relativeParts);

            return newPath;
        }
开发者ID:modulexcite,项目名称:ShellTools,代码行数:59,代码来源:PathHelper.cs


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