text: Encrypt a string by repeating i | C # implementation of the approach ; Function to return the encrypted String ; Number of times the current character will be repeated ; Repeat the current character in the encrypted String ; Driver code
code: using System ; class GFG { static String encryptString ( String str , int n ) { int i = 0 , cnt = 0 ; String encryptedStr = " " ; while ( i < n ) { cnt = i + 1 ; while ( cnt -- > 0 ) encryptedStr += str [ i ] ; i ++ ; } return encryptedStr ; } static public void Main ( ) { String str = " geeks " ; int n = str . Length ; Console . WriteLine ( encryptString ( str , n ) ) ; } }