new operator calls the default constructor of the specific type and assigns
the default value to the variable. In c# local variables must be initialized
before using that.
In case of Value types the default values are returned by default
constructors. Instead of declaring
System.String has constructors. It's just syntax sugar that you don't
generally have to new us a String directly. It is done implicitly for you
as a convenience.
Actually the only time I've ever used the String constructor directly is to
create a string preloaded with a number of characters:
No, about 56 I believe. Characters in .NET are Unicode, and IIRC
strings take up 12 bytes (header+string length) +
((number of characters+1 for the nul) rounded up to an even number) * 2
(Just before anyone says that strings aren't null-terminated in .NET -
they aren't as far as the API is concerned, but they are in memory,
presumably for interop reasons.)
Is it 255 bytes or not determined until there is an assignment with either
readline or direct assignment?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.