Program to print all substrings of a given string | C # program to print all possible substrings of a given string ; Function to print all sub strings ; Pick starting point ; Pick ending point ; Print characters from current starting point to current ending point . ; Driver program to test above function
using System ; public class GFG { static void subString ( string str , int n ) { for ( int len = 1 ; len <= n ; len ++ ) { for ( int i = 0 ; i <= n - len ; i ++ ) { int j = i + len - 1 ; for ( int k = i ; k <= j ; k ++ ) Console . Write ( str [ k ] ) ; Console . WriteLine ( ) ; } } } static public void Main ( ) { string str = " abc " ; subString ( str , str . Length ) ; } }