473,386 Members | 1,773 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Help with the magically instantiating collection class

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
Jul 21 '05 #1
1 1230
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

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Matthew Hood | last post by:
Here's the situation. I am developing an ASP.NET web application. Most of my forms will be accessing a database (MS Access) for either record creation/deletion/updating or for list lookups. The...
2
by: Cider123 | last post by:
Trying to figure out how to replicate the same interface as what a ListView control has. I have everything working for the most part, with exception of 1 minor setback. I can't seem to pass...
1
by: MrNobody | last post by:
What I was hoping to do was have a universal Windows Form which features a DataGrid. This Formcould be accessed from several different points of entry, each one may require a different style...
2
by: thechaosengine | last post by:
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...
2
by: FredC | last post by:
S Name Microsoft Windows XP Professional Version 5.1.2600 Service Pack 2 Build 2600 Total Physical Memory 1,024.00 MB MDE 2003 Version 7.1.3008 ..NET Framework 1.1 Version 1.1.4322 SP1...
9
by: Carl | last post by:
Hi, I have a class in .Net which I instantiate in my code behind on one of my aspx pages. When I am finished with the instance, what is teh best method of taking it out of memory. Should I...
2
by: HarishP | last post by:
Hi, How to avoid instantiating the class more than 10 times Harish.P Sr. Software Engineer Comat Technologies Pvt. Ltd., Bangalore Email: harish.p@comat.com
3
by: Nagesh | last post by:
hi, I have seen the winvnc(tightvnc server) source code in this I seen that class member funtions are calling without instantiating the object i.e. like vncService::ShowDefaultProperties() where...
2
by: hcaptech | last post by:
This is my Test.can you help me ? 1.Which of the following statement about C# varialble is incorrect ? A.A variable is a computer memory location identified by a unique name B.A variable's name...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.