> public string BugOrFeature()
> {
[quoted text clipped - 14 lines]
>
> 0123456789
You have an error in your function: sb is not a known identifier. I have
the following program:
---8<---
using System;
using System.Text;
class App
{
static void Main()
{
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());
Console.WriteLine(sb3.ToString());
}
}
--->8---
It prints this on the console:
---8<---
0123456789 wert wert
--->8---
Can you modify this program to reproduce your problem?
-- Barry

Signature
http://barrkel.blogspot.com/
Bill - 14 Jul 2006 23:16 GMT
Thanks Barry,
I've been looking in the "Text Visualizer" in the Locals window. For some
reason it dosen't display the whole string even when the "Wrap" textbox is
checked.
I see whats happening though, the entire declared length of the char array
is being copied into sb3. I had anticipated that StringBuilder would
interpret the first '\0' in the char array as the end of the useful content
of the array like it would in a string.
> > public string BugOrFeature()
> > {
[quoted text clipped - 52 lines]
>
> -- Barry
Carl Daniel [VC++ MVP] - 15 Jul 2006 00:02 GMT
> Thanks Barry,
>
[quoted text clipped - 7 lines]
> content
> of the array like it would in a string.
That's in C or C++. The CLR string types consider \0 to be just another
character - as valid as any other.
-cd
Marcin Hoppe - 17 Jul 2006 10:07 GMT
>>I've been looking in the "Text Visualizer" in the Locals window. For some
>>reason it dosen't display the whole string even when the "Wrap" textbox is
>>checked.
>
> That's in C or C++. The CLR string types consider \0 to be just another
> character - as valid as any other.
That's right, but strange things happen in VS.NET debugger, according to
Jon Skeet:
http://www.yoda.arachsys.com/csharp/strings.html
"Also, some versions of VS.NET will stop displaying the contents of the
string at the first null character, and evaluate its Length property
incorrectly, calculating the value itself instead of asking the managed
code. Again, it then considers the string to finish at the first null
character."

Signature
Marcin Hoppe