how to search for a string in text file in C#
<p>I am working on text file..i want to know how to search for a string in text file and then perform the operations on that string.I have written a code but there is some problem with  "<strong>if condition</strong>",when the particular string comes,the control skips to the next line..it doesnot perform any operation on that string..
Below is the line from text file from which i am trying to find "MerchantNo:105838015" and then performing Substring operation on it to get only the number..There is a space in between the line..
MERCHANTNO:105838015                                                    AGENT CODE 00913</p>

<p>And this is the code:</p>

<pre><code>    StreamReader sr = new StreamReader(fldr);
        string line = null;

        while ((line = sr.ReadLine()) != null)
        {
            str = line.Trim().Split(' ');
            for (int i = 0; i &lt; str.Length; i++)
            {
                if (str.ToString().ToUpper().Contains("MERCHANTNO:105838015"))
                {
                        //str = line.Split(' ');
                        string MNo1 = line.Substring(15, 23);
                        MNo = Convert.ToInt32(MNo1.ToString());
                }
                break;

            }

            //MessageBox.Show("Line is:" +line);
        }

        MessageBox.Show("MerchantNo is:" +MNo);
</code></pre>

<p>Please do say me what i have to do??   </p>
