Pick starting point in outer loop and lengths of different strings for a given starting point
for ( int i = 0 ; i < n ; i ++ ) for ( int j = 1 ; j <= n - i ; j ++ ) Console . WriteLine ( str . Substring ( i , j ) ) ; }