Calculate percentage wise stats using C sharp?
<p>i want to find the stats that will calculate percentage and give results in following format :
 WX GSA search % = GSA occurrences / GSA occurrences + Search occurrences + ADVSearch occurrences * 100 i.e. in this case it should give like :  3 / 3 + 2 + 2 * 100 = 42.8</p>

<p>I have tried code that will give occurrences of every search :</p>

<p>My code is here :</p>

<pre><code> class Program
{
    static void Main()
    {
        System.IO.StreamReader myFile =
        new System.IO.StreamReader(@"C:\Users\karansha\Desktop\sample log.txt");
        string myString = myFile.ReadToEnd();
        Console.WriteLine(TextTool.CountStringOccurrences(myString, "WX Search"));   // WX Rule Based Search.
        Console.WriteLine(TextTool.CountStringOccurrences(myString, "WX GSA Search"));  // WX GSA Search.
        Console.WriteLine(TextTool.CountStringOccurrences(myString, "WX ADVSearch"));   //WX Form Based Search.
        // keep screen from going away
        // when run from VS.NET
        Console.ReadLine();
    }
}
public static class TextTool
{
    public static int CountStringOccurrences(string text, string pattern)
    {
        int count = 0;
        int i = 0;
        while ((i = text.IndexOf(pattern, i)) != -1)
        {
            i += pattern.Length;
            count++;
        }
        return count;
    }
}
</code></pre>
