title: string.Replace() and string.Split() in c#
body: <p>i have a bunch of stored procedure script which i stored in an array. Each array contain a procedure (i.e normal create procedure ......). Howver, when passing to the array, the spaces in text are replaced with \t and \r in the array and the next line are replcaed with \n . I now want to break each procedure text in to words and store in an array. however the split function</p>
  
  <pre><code>for (int i = 0; i &lt; text.Length; i++)
  {
    string[] words = new string[text[i].Split('\t', '\n').Length];
  
  
  }
  </code></pre>
  
  <p>the above array words however when i checked, hold strings of a null value. It does not returns the words as it suppose to. I thought may be i have to replace the \n\r\t before splitting, like below...\</p>
  
  <pre><code>text[i].Replace("\n", string.Empty)
  </code></pre>
  
  <p>The above still does not work. Please any help would be appreciated. I want to split the text in to string of words. Below is the whole method snapshot. The method receives array of values procedure names, i want the method to extract the procedure text of each given name and then split each storedprocedure text in to words which i will later use. I want to loop through, perform a simple search by determining what word follows after the other.</p>
  
  <p><strong>Update</strong> </p>
  
  <pre><code>private void text(string[] array)
         {
             DataSet ds = new DataSet();
             string sql = "";
             progressBar1.Value = progressBar1.Minimum;
  
             using (SqlCommand command = new SqlCommand())
             {
                 string[] text = new string[array.Length];
                 string[] name = new string[array.Length];
                 for (int i = 0; i &lt; array.Length; i++)
                 {
                     command.Parameters.Clear();
                     sql = @"SELECT DISTINCT so.name, so.type,text FROM sys.sysobjects so with (nolock) INNER JOIN sys.syscomments sc with (nolock)
                                 ON so.id=sc.id WHERE name=@name";
                     command.Connection = getconnection();
                     command.CommandText = sql;
                     command.CommandType = CommandType.Text;
                     command.Parameters.AddWithValue("@name", array[i].ToString());
  
  
                     using (SqlDataAdapter adp = new SqlDataAdapter(command))
                     {
  
  
                         ds = new DataSet();
                         adp.Fill(ds);
                     }
                     if (ds.Tables[0].Rows.Count &gt; 0)
                     {
  
  
                         for (int j = 0; j &lt; ds.Tables[0].Rows.Count; j++)
                         {
  
                             text[i] = ds.Tables[0].Rows[0]["text"].ToString();
                             name[i] = ds.Tables[0].Rows[0]["name"].ToString();
                         }
                     }
                     double e = (Convert.ToDouble(i) / Convert.ToDouble(array.Length));
                     progressBar1.Value = Convert.ToInt16(e * 100);
                 }
  
                 int count = 0 ;
  
                 for (int i = 0; i &lt; text.Length; i++)
                 {
  
                     text[i].Replace("\n", string.Empty); 
  
                     string[] words = new string[text[i].Split(new string[] { "\t", "\n" }, StringSplitOptions.RemoveEmptyEntries).Length];
  
                     for(int j = 0; j &lt; words.Length ; j++)
                     {
                        // words[j] = text[i].Split(new string { " " }, StringSplitOptions.None);// = words[j].;
                         words[j] = words[j];
                     }
                 }
  
             }
         }
  </code></pre>