Hamming Distance between two strings | C # program to find hamming distance b / w two string ; function to calculate Hamming distance ; Driver code ; function call
using System ; class GFG { static int hammingDist ( String str1 , String str2 ) { int i = 0 , count = 0 ; while ( i < str1 . Length ) { if ( str1 [ i ] != str2 [ i ] ) count ++ ; i ++ ; } return count ; } public static void Main ( ) { String str1 = " geekspractice " ; String str2 = " nerdspractise " ; Console . Write ( hammingDist ( str1 , str2 ) ) ; } }