On 2007-11-01 08:28:00 -0700, Marc Gravell <ma**********@gmail.comsaid:
it might surprise Pete, though:
<q>and possibly even more efficient than
the StringBuilder code Marc posted</q>
;-p
It doesn't surprise me. That's why I used the word "possibly". I
accepted the possibility that the Lines property is simply a wrapper
and took that into account in my reply.
And even though it turns out that the current implementation is no
different, that does not rule out a possible change in the future. The
fact is that storing all of the text in the control as a single string
array creates performance trade-offs, and it's always possible that in
the future it will be changed to allow better performance for the
line-oriented access methods and properties of the control.
It's well and good that you can inspect the current implementation
based on reflection, but IMHO it's a bad idea to use that information
as a determining factor in implementing one's own code. There's a
reason the implementation is normally opaque: the client of the
implementation shouldn't be depending on the specific implementation.
Finally, I will note that the Lines implementation _is_ more efficient
than the code you posted, even if only slightly. So :p right back
atchya.
Pete