C# Question

The new line before the parenthesis character

I have an string array data like this:

GAZIOSMANPASA-KARADENIZ (ISTANBUL)


i want to before each parenthesis a sub down the line, like this:

GAZIOSMANPASA-KARADENIZ

(ISTANBUL)


and then i want to write textblock. How or what can I do? I'd appreciate it if you could give an example.

ASh ASh
Answer

you can use String.Replace method to insert line breaks (Environment.NewLine) before each parenthesis and then assign result to TextBlock.Text property (or to a view model property which used in a binding)

string text = "GAZIOSMANPASA-KARADENIZ (ISTANBUL)";
textBlock.Text = text.Replace(" (", Environment.NewLine +"(");