[Mono-list] Interpretation of the spec for StringBuilder..
Marcey, Joel I
joel.i.marcey@intel.com
Wed, 11 Jul 2001 10:09:08 -0700
Hey Marcin,
Good catch! You are correct in your assumption that the padding should be on
the right (i.e. at the end of the string value) if the specified length is
greater than the length of the current instance.
Thanks,
- Joel Marcey
The views and statements expressed here do not necessarily reflect those of
Intel Corporation, its subsidiaries or its employees.
-----Original Message-----
From: Marcin Szczepanski [mailto:marcins@zipworld.com.au]
Sent: Tuesday, July 10, 2001 9:22 PM
To: mono-list@ximian.com
Subject: [Mono-list] Interpretation of the spec for StringBuilder..
Already found something that's a bit weird and I've barely started!
This is the description for the StringBuilder.Length property: If the
specified length is less than the current length, the StringBuilder is
truncated to the specified length. If the specified length is greater than
the current length, the Capacity of the current instance is set to the
specified length, padding its string value with spaces on the left.
The first bit of this is fine, however the second seems a bit confusing.
It's saying to put the padding on the left?!
So if I have a string "foo" and I do Length = 6 then the string will be:
" foo"
and not
"foo ", which would make more sense.
What does everyone else think??
Actually, I'll try the MS implementation and see what it does... Okay, the
MS implementation puts the padding on the right, ie. This code: [...]
StringBuilder sb = new StringBuilder( "foo" );
Console.WriteLine( ">{0}<", sb.ToString() );
sb.Length = 6;
Console.WriteLine( ">{0}<", sb.ToString() ); [...]
Gives this result:
>foo<
>foo <
Is this a case of LAMESPEC or am I just misreading the spec?? Either
that or they just wrote left where they meant right :)
Thanks for your time :)
_______________________________________________
Mono-list maillist - Mono-list@ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list