c# winform
iam trying code mirror from textbox1 input like below if user not used bracket like below
textbox1
8-a
4-b
2-c
50-d
100-a
output should be
8-a
4-b
2-c
50-d
100-a
100-a
50-d
2-c
4-b
8-a
Here is my code
private void button1_Click(object sender, EventArgs e)
{
//without bracket mirror working code
// Get the input from textBox1
string input = textBox1.Text;
// Split the input into lines
string[] lines = input.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
// Reverse the lines
string[] reversedLines = lines.Reverse().ToArray();
// Append the reversed lines to the original input
string output = input + Environment.NewLine + string.Join(Environment.NewLine, reversedLines);
// Set the result back to textBox1
textBox1.Text = output;
}
but i want to impliment this code if user used bracket like below then output should be mirror with bracket.
textbox1 input
8-a
[4-b
2-c]5
50-d
100-a
output should be
8-a
[4-b
2-c]5
50-d
100-a
100-a
50-d
[2-c
4-b]5
8-a