String length in bytes

String length in bytes

am 25.01.2008 11:32:00 von Guy

Being lazy here...

How many bytes are used to store a string?

I would guess the (number of characters * 2) + 4

is that correct?

cheers

Guy

Re: String length in bytes

am 25.01.2008 20:26:09 von skeet

guy wrote:
> Being lazy here...
>
> How many bytes are used to store a string?
>
> I would guess the (number of characters * 2) + 4
>
> is that correct?

Well, where did you get the 4 from? I believe it's more like 12 or 16 -
but the basics are right.

--
Jon Skeet -
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk

Re: String length in bytes

am 26.01.2008 00:01:12 von Dejan Stanic

http://www.codeproject.com/KB/dotnet/strings.aspx

LP,
Dejan

Re: String length in bytes

am 30.01.2008 09:20:00 von Guy

Many thanks,

just what I needed!

Guy

"Dejan Stanic" wrote:

> http://www.codeproject.com/KB/dotnet/strings.aspx
>
> LP,
> Dejan
>
>