> You use StringBuilder when you expect the buffer to be written to, as
> instances of the String class is are immutable. It wouldn't be very good to
> declare instances of a class immutable and then allow something to change
> it, would it? =)
Right!
> The general pattern for using a StringBuilder is to intialize the buffer
> in the StringBuilder to the size you need, and then pass the StringBuilder
> for the parameter (of course, the P/Invoke declaration has to have a
> StringBuilder type as well).
Yup, that's just what I do. I initialize StringBuilder's buffer to a
certain size, and the win32 function that writes to it wants to know
this size, so I pass it in as well as the StringBuilder.
(I noted that it doesn't work with the "out" qualifier, because it is
not an "out" parameter, since you have to initialize it first, and the
function expects that. It was a little confusing at first. And it
doesn't help when the win32 function I'm trying to use plain doesn't
work)
Thanks, Nicholas
Zytan