All pastes #623743 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-07-17 20:18 UTC
rendered paste body
        private void button1_Click(object sender, EventArgs e)
        {
            String Elapsed;
            System.Collections.ArrayList AL = LineArray(textBox1.Text, out Elapsed);
            this.Text = Elapsed;
            for (int I = 0; I < AL.Count; I++)
            {
                listBox1.Items.Add(AL[I]);
            }
        }
        public System.Collections.ArrayList LineArray(string Script, out string ElapsedTime)
        {
            String Code = Script + System.Environment.NewLine;
            System.Collections.ArrayList LineList = new System.Collections.ArrayList();
            System.Diagnostics.Stopwatch SW = new System.Diagnostics.Stopwatch();
            SW.Start();
            while (true)
            {
                try
                {
                    String[] Line = System.Text.RegularExpressions.Regex.Split(Code, "\r\n");
                    String Temp = Code.Remove(0, (Code.IndexOf("\r\n") + 2));
                    Code = Temp;
                    LineList.Add(Line[0]);
                }
                catch
                {
                    break;
                }
            }
            SW.Stop();
            ElapsedTime = "Line Splitting: " + SW.ElapsedMilliseconds.ToString() + "ms";
            return LineList;
        }