Hi
I need an efficient method to convert a string object to it's byte[]
equivalent.
I know there are LOTS of methods, but they lack in efficiency. All
methods allocate new memory to create the byte[] array. Of course,
when memory allocation occurs, then naturally extra processing power
is needed.
To more explicit, MFC introduced a super-efficient method of dealing
with this situation. As far as I remember (I switched from MFC
to .NET
few years ago), MFC's CString class has a method with the following
signature:

byte[] GetBuffer()


This method "blocks" the CString instance until ReleaseBuffer()
method
is called. Again, maybe the method names are not quite as I remember,
but the important thing is the principle.
The marvelous result is that you may freely iterate through the
byte[]
array returned by GetBuffer() method and even modify it (with respect
to some limits, of course), and all this, without allocating new
memory.
My question is: using MemoryStream class will do the job for me? I
mean, there is a method called GetBuffer(), but will it allocate new
memory or not, as it is not stated in MS documentation.


Thanks

Re: String to byte[] reloaded by Jon

Jon
Sat Feb 10 10:57:57 CST 2007

nano2k <adrian.rotaru@ikonsoft.ro> wrote:
> I need an efficient method to convert a string object to it's byte[]
> equivalent.

Please read my reply in the C# group and try to avoid multiposting in
the future.

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Re: String to byte[] reloaded by guffa

guffa
Sat Feb 10 12:27:12 CST 2007

Please read my reply in the C# group and try to avoid multiposting in
the future.

--
Göran Andersson
_____
http://www.guffa.com

Re: String to byte[] reloaded by nano2k

nano2k
Mon Feb 12 02:51:41 CST 2007

Sorry about that and thanks for your responses.
Anyway, is there a way to put the same question in 2 or more groups?

Thanks.


G=F6ran Andersson a scris:
> Please read my reply in the C# group and try to avoid multiposting in
> the future.
>
> --
> G=F6ran Andersson
> _____
> http://www.guffa.com