Program to print all substrings of a given string | C # program to print all substrings of a string ; Function to print all substring ; Pick starting point in outer loop and lengths of different strings for a given starting point ; Driver code
using System ; public class GFG { public static void SubString ( String str , int n ) { for ( int i = 0 ; i < n ; i ++ ) for ( int j = 1 ; j <= n - i ; j ++ ) Console . WriteLine ( str . Substring ( i , j ) ) ; } public static void Main ( ) { String str = " abcd " ; SubString ( str , str . Length ) ; } }