473,508 Members | 2,289 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1235
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
3931
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
1394
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
1098
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
1055
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
2257
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
1129
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
1311
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
4931
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
9997
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
7224
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
7323
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,...
1
7039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5626
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5050
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4706
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1553
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
415
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.