Re: Counting the number of bytes used by characters of a String
From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 12/12/04
- Next message: Daniel O'Connell [C# MVP]: "Re: All .NET Languages are no longer equal."
- Previous message: newsgroupie: "Is it possible to..."
- In reply to: Nicolas: "Re: Counting the number of bytes used by characters of a String"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 12 Dec 2004 21:23:24 -0000
Nicolas <nicolas@serpe.org> wrote:
> > In what encoding? In the CLR itself, or in a particular encoding?
>
> Just as it is, I mean the space it takes on RAM.
> I think a String class stores a string as an array of char, just want to
> know what place this array occupies.
It's not actually an array of char itself - string is a very unusual
type, in that the size of the object itself depends on the contents.
I believe the size of the object is 20+(n/2)*4 where n is the number of
characters in the string. (The result of n/2 is rounded down.)
-- Jon Skeet - <skeet@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
- Next message: Daniel O'Connell [C# MVP]: "Re: All .NET Languages are no longer equal."
- Previous message: newsgroupie: "Is it possible to..."
- In reply to: Nicolas: "Re: Counting the number of bytes used by characters of a String"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|