Introduction
In this article, we will explore a method to find all possible subsets of a string in C#.
Below are a few examples of inputs and Outputs.
Examples
- Input: ABC
- Output: A AB ABC BC C
- Input: RUN
- Output: R RU RUN U UN N
This is an essential technical interview question that may be posed to beginner, intermediate, and experienced candidates.
We previously covered the following.
- How to Reverse Number in C#
- How to Reverse a String in C#
- Palindrome String Program in C#
- Palindrome Number in C#
- How to Reverse Order of the Given String
- How To Reverse Each Word Of Given String
- How To Remove Duplicate Characters From String In C#
- Bubble Sort Algorithm
- How To Count the Occurrence Of Each Character In The String In C#
- Decimal to Binary Conversion in C#
- Binary To Decimal Conversion in C#
Let’s start,
using System.Text;
Console.WriteLine("Enter a string");
var str = Console.ReadLine();
for (int i = 0; i < str.Length; i++)
{
StringBuilder sb = new StringBuilder(str.Length - i);
for (int j = i; j < str.Length; j++)
{
sb.Append(str[j]);
Console.Write(sb + " ");
}
}
Console.ReadLine();
Let us execute the program and see the output.
Output

Try with another input.

We have learned a method to find all possible subsets of a string in C#. I hope you find this article enjoyable and useful.

PandoraPosted Jul 10, 2026, 9:58 AM
What would the output be for the input "ABA"? <a href="https://taggame.io">tag game</a>