text: Check if string is right to left diagonal or not | C # program to check if the given string is right to left diagonal or not ; Function to check if the given string is right to left diagonal or not ; Iterate over string ; If character is not same as the first character then return false ; Driver Code ; Given String str ; Function call
code: using System ; class GFG { public static bool is_rtol ( String s ) { int tmp = ( int ) ( Math . Sqrt ( s . Length ) ) - 1 ; char first = s [ tmp ] ; for ( int pos = tmp ; pos < s . Length - 1 ; pos += tmp ) { if ( s [ pos ] != first ) { return false ; } } return true ; } public static void Main ( String [ ] args ) { String str = " abcxabxcaxbcxabc " ; if ( is_rtol ( str ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }