Program for length of a string using recursion | C # program to calculate length of a string using recursion ; Function to calculate length ; if we reach at the end of the string ; Driver program to test above function
using System ; public class GFG { private static int recLen ( string str ) { if ( str . Equals ( " " ) ) return 0 ; else return recLen ( str . Substring ( 1 ) ) + 1 ; } public static void Main ( ) { string str = " GeeksforGeeks " ; Console . WriteLine ( recLen ( str ) ) ; } }