Not sure the exact point that troubles you.
Keep in mind that .NET applications are under the control of a runtime. This
runtime takes care of "initializing" variables instead of letting whatever
was in memory before...
I don't really see though how it's relate to the "automagically instantiated
collection". If you mean the variable is null, the collection is not
instanciated. Tehcnically you just have a pointer to your collection that
currently points to nothing. It will be instantiated actually when you "new"
the variable.
Technically :
- space is reserved for variables
- this space is filled with 0
Objects are under the hood pointers ie. the variable for objects will be
null (ie. pointing to nowhere) and you'll have to "new" the variavble to
really allocate an object.
Patrice
--
"thechaosengine" <sh856531@microsofts_free_email_service.com> a écrit dans
le message de news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi everyone,
I posted a question earlier about a collection class that I'd made
seemingly getting instantiated magically after a class that contained a variable of
that type had its constructor called.
The constructor didnt touch the collection class and defineately didn't
initialise it.
Some one suggested the following reason as what is happening.
If anyone can help with what I've said down below i'd be very greatful:
Thanks
Field initialization
The initial value of a field, whether it be a static field or an
instance field, is the default value (§5.2) of the field's type. It is not
possible to observe the value of a field before this default initialization has
occurred, and a field is thus never "uninitialized".
I'm not really sure what to make of that. How come, if I dont initialise,
by means of a constructor, a string for example - its null until I give it
something?
Thanks