G
Guest
Ok, so we have the following code and it produces the result seen immediately
following the function.
public string BugOrFeature()
{
StringBuilder sb1 = new StringBuilder();
StringBuilder sb2 = new StringBuilder();
StringBuilder sb3 = new StringBuilder();
char[] cTxtSeg = new char[48];
sb1.Append("0123456789abcdefghij");
sb1.CopyTo(0, cTxtSeg, 0, 10);
sb2.Append(cTxtSeg);
sb3.AppendFormat("{0} wert wert", sb2.ToString());
return sb.ToString();
}
0123456789
Howcome the text following the format specifier in the AppendFormat() call
doesn't appear in the output string? I suspect that it has something to do
with the fact that the unused chars in the char array are initialized to '\0'
but it seems like StringBuilder ought to be smart enough to deal with that.
Is this correct behavior for the AppentFormat() member?
One workaround would be to use string.Substring() but we are led to believe
that StringBuilder (with a properly set capacity) should be more efficient
for these kinds of parsing operations.
Bill
following the function.
public string BugOrFeature()
{
StringBuilder sb1 = new StringBuilder();
StringBuilder sb2 = new StringBuilder();
StringBuilder sb3 = new StringBuilder();
char[] cTxtSeg = new char[48];
sb1.Append("0123456789abcdefghij");
sb1.CopyTo(0, cTxtSeg, 0, 10);
sb2.Append(cTxtSeg);
sb3.AppendFormat("{0} wert wert", sb2.ToString());
return sb.ToString();
}
0123456789
Howcome the text following the format specifier in the AppendFormat() call
doesn't appear in the output string? I suspect that it has something to do
with the fact that the unused chars in the char array are initialized to '\0'
but it seems like StringBuilder ought to be smart enough to deal with that.
Is this correct behavior for the AppentFormat() member?
One workaround would be to use string.Substring() but we are led to believe
that StringBuilder (with a properly set capacity) should be more efficient
for these kinds of parsing operations.
Bill