Created
November 2, 2017 09:08
-
-
Save Hameds/667c58e36aef8c57ce55bcd015317e4a to your computer and use it in GitHub Desktop.
This file contains hidden or 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 ThirtyDaysOfTDD.UnitTests | |
| { | |
| public class StringUtils | |
| { | |
| public int FindNumberOfOccurences(string sentenceToScan, string characterToScanFor) | |
| { | |
| throw new ArgumentException(); | |
| var stringToCheckAsCharacterArray = sentenceToScan.ToCharArray(); | |
| var characterToCheckFor = Char.Parse(characterToScanFor); | |
| var numberOfOccurenes = 0; | |
| for (var charIdx = 0; charIdx < stringToCheckAsCharacterArray.GetUpperBound(0); charIdx++) | |
| { | |
| if (stringToCheckAsCharacterArray[charIdx] == characterToCheckFor) | |
| { | |
| numberOfOccurenes++; | |
| } | |
| } | |
| return numberOfOccurenes; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment