473,661 Members | 2,432 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
Nov 16 '05 #1
2 1061
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 "initializi ng" variables instead of letting whatever
was in memory before...

I don't really see though how it's relate to the "automagica lly 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@micro softs_free_emai l_service.com> a écrit dans
le message de news:%2******** ********@TK2MSF TNGP12.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

Nov 16 '05 #2
"thechaosengine " <sh856531@micro softs_free_emai l_service.com> wrote:
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?


String is a reference type, and the "default value" for any reference
type is null. As the spec says, "the initial value of a field ... is
the default value of the field's type"- i.e. a string that has not
been explicitly initialised will be null.

P.
Nov 16 '05 #3

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

Similar topics

1
3950
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 problem I have is my boss constantly wants to revise table and field names and I am the one that has to make sure everthing works after the fact. What I want to do is create 2 classes. The first one is my "Record" wrapper class that will map...
1
1255
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 called. The constructor didnt touch the collection class and defineately didn't initialise it. Some one suggested the following reason as what is happening.
2
1404
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 the "ListViewItem" object to a Collection on "MyControl".
1
1103
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 (different columns to show, different RowFilter expression, etc..) So I created the form and a class which holds several configuration objects, such as TableStyle, a string to hold a RowFilter expression, etc... What I wanted was each different...
2
2267
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 Microsoft Visual C# .NET 69462-335-0000007-18707 Crystal Reports for Visual Studio .NET AAP50-GS0000S-WCK00C3 The code below shows the instantiation of multiple V47 objects. These
9
1141
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 set it to nothing or can I dispose of it? Thanks,
2
1316
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
2
1661
by: SStory | last post by:
Here is the situation. I want to display Icons, Type of file etc from a file extension. Upon initial program load I may only need icons for certain files. But other operations will require showing all filetypes and icons. I have an object that has extension, desc (like Word Document) and then icon, which is nothing to start with. I have a collection object of these and when it is initialized it goes to
3
4938
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 vncService is a class name not an refrence or instantiated object. is the above notation is possible or not?if yes how should i declare that class(vncService) so that i can call without instantiating the object. If any of u know pls answer to...
2
10024
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 is used to access and read the value stored in it C.A variable is allocated or deallocated in memory during runtime D.A variable can be initialized at the time of its creation or later 2. The.……types feature facilitates the definition of classes...
0
8341
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8754
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7362
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6181
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5650
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4343
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1984
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1740
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.