I want to sum the total Elapsed time through input text file?
<p>I want to sum the total "Elapsed time" for "GSA Search" only, using C sharp :</p>

<p>Following is my log file :</p>

<pre><code>WX Search = Server:nomos-scanner.corp.com User:vibsharm appGUID: wx Elapsed Time:975ms SaveSearchID:361
WX Search = Server:nomos-scanner.corp.com User:vibsharm appGUID: wx Elapsed Time:875ms SaveSearchID:361
GSA Search = Server:nomos-scanner.corp.com User:gulanand appGUID: wx Elapsed Time:890ms SaveSearchID:361
GSA Search = Server:nomos-scanner.corp.com User:vibsharm appGUID: wx Elapsed Time:887ms SaveSearchID:361
GSA Search = Server:nomos-scanner.corp.com User: gulanand appGUID: wx Elapsed Time:875.5ms SaveSearchID:361
GSA Search = Server:nomos-scanner.corp.com User:vibsharm appGUID: wx Elapsed Time:877.6ms SaveSearchID:361
</code></pre>

<p>Code i have tried is :</p>

<pre><code>string searchKeyword = "WX GSA Search";
            string fileName = @"C:\Users\karan\Desktop\Sample log file.txt";
            string[] textLines = File.ReadAllLines(fileName);

            List&lt;string&gt; results = new List&lt;string&gt;();

            foreach (string line in textLines)
            {
                if (line.Contains(searchKeyword))
                {
                    results.Add(line);
                }
            }

            string x = string.Join(",", results);
            List&lt;string&gt; time = new List&lt;string&gt;();
            Regex regex = new Regex(@"Elapsed Time:(?&lt;timevalue&gt;\d+(?:\.\d)?)ms");
            MatchCollection matches = regex.Matches(x);
            foreach (Match match in matches)
            {
                var value = match.Groups["timevalue"].Value;
                if (!time.Contains(value)) time.Add(value);
            }
</code></pre>
