Skip to content

Instantly share code, notes, and snippets.

@royosherove
Created July 28, 2011 21:27
Show Gist options
  • Save royosherove/1112609 to your computer and use it in GitHub Desktop.
Save royosherove/1112609 to your computer and use it in GitHub Desktop.
Pure TDD
using System;
namespace ChapterOneExample. Utilities
{
public class StringUtilities
{
public int CountOccurences(string stringToCheck,
string stringToFind)
{
var stringAsCharArray = stringToCheck. ToCharArray( ) ;
var stringToCheckForAsChar =
stringToFind. ToCharArray() [ 0] ;
var occuranceCount = 0;
for (var characterIndex = 0;
characterIndex < stringAsCharArray. GetUpperBound( 0) ;
characterIndex++)
{
if (stringAsCharArray[ characterIndex] ==
stringToCheckForAsChar)
{
occuranceCount++;
}
}
return occuranceCount;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment