R
ramhog
Hello all,
I would like to use AppendFormat to replace tokens in a string with
actual string values. The problem I am running into however is that my
string uses {} around a string that I do not want formatted. Is there
a way to tell the AppendFormat method not to see certain {} as a token
to be replaced?
In the example here, I want to replace {0} with the string "Test" but
leave the string {SQL Server} just like it is in the string.
string MBConnectBase = @"{0} and {SQL Server}";
try
{
System.Text.StringBuilder builder = new
System.Text.StringBuilder();
string format = MBConnectBase;
builder.AppendFormat(format, "Test");
System.Diagnostics.Debug.WriteLine(builder.ToString());
}
catch(System.Exception exc)
{
MessageBox.Show(exc.Message.ToString());
}
I would like to use AppendFormat to replace tokens in a string with
actual string values. The problem I am running into however is that my
string uses {} around a string that I do not want formatted. Is there
a way to tell the AppendFormat method not to see certain {} as a token
to be replaced?
In the example here, I want to replace {0} with the string "Test" but
leave the string {SQL Server} just like it is in the string.
string MBConnectBase = @"{0} and {SQL Server}";
try
{
System.Text.StringBuilder builder = new
System.Text.StringBuilder();
string format = MBConnectBase;
builder.AppendFormat(format, "Test");
System.Diagnostics.Debug.WriteLine(builder.ToString());
}
catch(System.Exception exc)
{
MessageBox.Show(exc.Message.ToString());
}