Hello everyone, Here I am going to write a Program to find all substrings from a String. This example code iterate through all possible lengths of a substring.

C# Program to find all substrings from a String

Here is the source code to find all substrings from a String.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
static void Main(string[] args)
Console.WriteLine("Enter a String");

string sInput = Console.ReadLine(); ;
// Avoid full length.
for (int length = 1; length < sInput.Length; length++)
// End index is tricky.
for (int start = 0; start <= sInput.Length - length; start++)
string sSubString = sInput.Substring(start, length);



View More:


I hope you loved this post. Please don’t hesitate to comment for any technical help. Your feedback and suggestions are welcome to me.

Thank You.

Explore post tags

Warning: mysqli_num_fields() expects parameter 1 to be mysqli_result, bool given in C:\inetpub\vhosts\debugonweb.com\httpdocs\wp-includes\wp-db.php on line 3353