I can't seem to find this info anywhere, what is the call to get the number of bytes? I know I can do ToString() and then get the number but that is quite inefficient.
Printable View
I can't seem to find this info anywhere, what is the call to get the number of bytes? I know I can do ToString() and then get the number but that is quite inefficient.
Ok I found it, it's .Length. I was trying with trial and error but I always have trouble figuring out the spelling to that word so I must have gotten it wrong. :D I wish they would all use Size. So much easier. lol
Yep, sometimes, Length, sometimes Size, sometimes Count and sometimes Count()...
Maybe because count of elements in the collection cannot be neccessary same as lenght of the space allocate ;-) And Count() is the price of extension method. But despite I see the reasons, I think it could be unified.
itn count = Encoding.ASCII.GetByteCount(string);
Yes, I think the problem is actually the English language, not the C# language.
Have you heard of Msdn?
StringBuilder class
In Msdn, all the constructors, properties, methods, events and so on are listed for each class.
If you are using a new class, check it out in Msdn and notice what's available - even if you don't need it this time, you might remember enough for next time.