The Difference between String and StringBuilder in C#
AramT
55.5K views
Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
The equation to know the size of String in memory, for a Unicode string with a maximum length of 2,147,483,647 characters, is as follows:
80 + [16 * Length] bits
Example:
string stringSample = "Tech.io" //7 Characters
Then using the string equation:
80 + (16 * 7) = 192 Bits
Same equation divided by 8, will get us the size in bytes:
(10 + [2 * Length] bytes) = 10 + (2 * 7) = 24 Bytes
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content