Saturday, 17 August 2024

How to find all possible substring of a given string?

 string str = "abcd";


for(int i=0;i<str.Length;i++)

{

    

    for (int j=i,k=1;j<str.Length;j++,k++)

    {

        

        Console.WriteLine(str.Substring(i, k));

      

    }



}

No comments:

Post a Comment