Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int MatchingBeginningCharactersInTwoStringsIgnoringCase(string _string1, string _string2){
- int matching = 0;
- int numCharToCompare = 0;
- string first = _string1.ToLower();
- string two = _string2.ToLower();
- char[] firstArray = first.ToCharArray();
- char[] secondArray = two.ToCharArray();
- if(first.Length > two.Length){
- numCharToCompare = two.Length;
- }else{
- numCharToCompare = first.Length;
- }
- for(int i=0; i < numCharToCompare; i++){
- if(firstArray[i] == secondArray[i]){ matching++;}
- }
- return matching;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement