I have a List<String> with 1000 names. I want to find out the count of names which is starting with letter "S".
What will be the best option to do it?
If Linq is available
using System.Linq;
list.Where(s=>s!=null && s.StartsWith("S")).Count();
if Linq is not available.
int count=0;
foreach (string s in list) {
if (s!=null && s.StartsWith("S")) count++;
}