Created
July 28, 2011 21:27
-
-
Save royosherove/1112609 to your computer and use it in GitHub Desktop.
Pure TDD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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