How do I use a conditional operator inside a string?
Why is the value of this string missing TO_DATE( and ' the single quote? and what can I do to fix it?
StringBuilder sb = new StringBuilder();
//code...
sb.AppendLine(" '" + txtStatus.Text + "',");
sb.AppendLine(" TO_DATE(" + dtpEligDate.Value.ToString("yyyyMMddHHmmss") == "" ? "null" : dtpEligDate.Value.ToString() + "),");
sb.AppendLine(" '" + txtCoverageEndReason.Text == "" ? "null" : txtCoverageEndReason.Text + "',");
//code...
String value:
'',
7/19/2013 9:04:35 AM),
',
My understanding is that this is NOT caused by lack of escaping charecters, but because of the use of a conditional operator.
Thanks for the help!