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
The #1 tech hiring platform