Program to find the XOR of ASCII values of characters in a string | C # program to find XOR of ASCII value of characters in String ; Function to find the XOR of ASCII value of characters in String ; store value of first character ; Traverse String to find the XOR ; Return the XOR ; Driver code
using System ; class GFG { static int XorAscii ( String str , int len ) { int ans = ( str [ 0 ] ) ; for ( int i = 1 ; i < len ; i ++ ) { ans = ( ans ^ ( ( str [ i ] ) ) ) ; } return ans ; } public static void Main ( String [ ] args ) { String str = " geeksforgeeks " ; int len = str . Length ; Console . Write ( XorAscii ( str , len ) + " STRNEWLINE " ) ; str = " GfG " ; len = str . Length ; Console . Write ( XorAscii ( str , len ) ) ; } }