C# Program to find all substrings in a string
- Using following example we can determine the sub string in the given string .
class SubStringInString
{
static void Main()
{
string str = "abcdefghijklmn";
for (int i = 1; i < str.Length; i++)
{
for (int start = 0; start <= str.Length - i; start++)
{
string substr = str.Substring(start, i);
Console.WriteLine(substr);
}
}
Console.ReadLine();
}
}
No comments