instantiation in C#

Please support our C# advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2008
Posts: 10
Reputation: BioHazard90 has a little shameless behaviour in the past 
Solved Threads: 0
BioHazard90 BioHazard90 is offline Offline
Newbie Poster

instantiation in C#

 
0
  #1
Jan 15th, 2009
  1. class MyProgram
  2. {
  3. static void Main()
  4. {
  5. int[] integers; // declare array
  6. integers = new int[10]; // size array
  7. }
  8. }

In which line is the array actually instantiated?
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 17
Reputation: virang_21 is an unknown quantity at this point 
Solved Threads: 0
virang_21 virang_21 is offline Offline
Newbie Poster

Re: instantiation in C#

 
0
  #2
Jan 16th, 2009
Array get instantiated when you create it with new keyword:

integers = new int[10]; // size array

declaration can just create a reference.

int[] integers; // declare array
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 136
Reputation: cVz is an unknown quantity at this point 
Solved Threads: 7
cVz's Avatar
cVz cVz is offline Offline
Junior Poster

Re: instantiation in C#

 
0
  #3
Jan 16th, 2009
integers = new int[10];
Delphi & C# programmer deluxe...
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: instantiation in C#

 
0
  #4
Jan 16th, 2009
Yep.. Just because you've declared a container, doesnt automagically mean its made, thefore the new keyword gives you the default contents for that type
Last edited by LizR; Jan 16th, 2009 at 2:56 am.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 46
Reputation: BlackSun is an unknown quantity at this point 
Solved Threads: 4
BlackSun BlackSun is offline Offline
Light Poster

Re: instantiation in C#

 
0
  #5
Jan 17th, 2009
int[] integers = new int[10];

her u put ur refrence in the stack pointed to integers[0] in the heap
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 722 | Replies: 4
Thread Tools Search this Thread



Tag cloud for C#
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC