Probably not the most efficient, but I think this is an easy way to do this.
class Program { static void Main(string[] args) { Console.WriteLine(CountAllTheTimesThisStringAppearsInThatString("7,true,NA,false:67,false,NA,false:5,false,NA,false:5,false,NA,false", "true")); Console.WriteLine(CountAllTheTimesThisStringAppearsInThatString("7,true,NA,false:67,false,NA,false:5,false,NA,false:5,false,NA,false", "false")); } static Int32 CountAllTheTimesThisStringAppearsInThatString(string orig, string find) { var s2 = orig.Replace(find,""); return (orig.Length - s2.Length) / find.Length; } }
rjdevereux Jun 10 '10 at 17:27 2010-06-10 17:27
source share