C# Problem solving interview questions for .NET Developers
How to find all possible substring of a given string?
public class Program
{
public static void Main()
{
string input = "abcdef";
var sb = new StringBuilder();
for (int i = 0; i lesserthan input.Length; i++)
{
for (int j = i; j lesserthan input.Length; j++)
{
sb.Append(input[j]);
Console.WriteLine(sb.ToString());
}
sb.Clear();
}
Console.ReadLine();
}
}
Тэги:
#c# #problem_solving #interview_questions #interview #substring_of_given_string #substring