Re: String to byte[] reloaded
- From: "David Browne" <davidbaxterbrowne no potted meat@xxxxxxxxxxx>
- Date: Sat, 10 Feb 2007 18:41:16 -0600
"Jon Skeet [C# MVP]" <skeet@xxxxxxxxx> wrote in message news:MPG.20383e7ac4a41bc998d84a@xxxxxxxxxxxxxxxxxxxxxxx
<"David Browne" <davidbaxterbrowne no potted meat@xxxxxxxxxxx>> wrote:> No they don't. Use Encoding.GetBytes(string, int, int, byte[], int) to
> copy the bytes into an existing byte array. Of course, you'll have to
> allocate the array at some point first... I'm currently working on a
> BufferManager class which allows buffers to be reused etc, but I'm not
> sure it's really worth it here.
Have you seen System.ServiceModel.Channels.BufferManager in .NET 3.0?
I hadn't before, to be honest. Can't say I like the idea of having to
explicitly call ReturnBuffer - my buffers allow you access to the byte
array, but implement IDisposable so you can just do:
using (IBuffer buffer = manager.GetBuffer(...))
{
byte[] bytes = buffer.Bytes;
...
}
That's handy. Though if it's a public library I would worry that it could lead to inadvertent sharing of buffers.
David
.
- Follow-Ups:
- Re: String to byte[] reloaded
- From: Jon Skeet [C# MVP]
- Re: String to byte[] reloaded
- References:
- String to byte[] reloaded
- From: nano2k
- Re: String to byte[] reloaded
- From: Jon Skeet [C# MVP]
- Re: String to byte[] reloaded
- From: David Browne
- Re: String to byte[] reloaded
- From: Jon Skeet [C# MVP]
- String to byte[] reloaded
- Prev by Date: Re: String to byte[] reloaded
- Next by Date: Re: Is there a good way to turn regex patterns into properly-escaped c# regex patterns?
- Previous by thread: Re: String to byte[] reloaded
- Next by thread: Re: String to byte[] reloaded
- Index(es):
Relevant Pages
|