Reputation: 754
I have a rich textbox where the user will enter values like this with a line return after each line.
A12345
B12345
I want to reformat these values into a like this, to put in a SQL IN
clause
('A12345', 'B12345')
Note: the last value can't have a [,]
following.
Thanks!
Upvotes: 0
Views: 36
Reputation: 3858
Does it work for you?
string result = "(" + string.Join(",", textBox.Text.Split(new[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries).Select(s => "'" + s + "'")) + ")";
Upvotes: 1
Reputation: 61
You need to split the text using new line and return carriage.
string[] splitString = textstring.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);`
`
Upvotes: 1