Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 8th, 2005, 10:46 PM   #11
Dameon
Troll
 
Dameon's Avatar
 
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4 Dameon is on a distinguished road
Quote:
Originally Posted by Intimidat0r
im trying to write a file manager. its got this:
string[] directories = new string[10000];
directories = System.IO.Directory.GetFiles(path);
Elaborating on one of the responses, GetFiles returns a shiny, brand new array. For that reason, directories doesn't have to be initialized ahead of time. If it is, it's a waste of cycles as 10k strings get garbage collected.

Arrays are reference-type, in other words directories is a pointer to an array of strings. The "= new string[10000]" part creates an array of ten thousand references to empty strings.
http://msdn.microsoft.com/msdnmag/issues/02/02/NET/
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270
Dameon is offline   Reply With Quote
Old Dec 22nd, 2005, 10:15 PM   #12
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
Damn you reference types, I want real array pointers back.
Here's your thousand real strings.
Dim PointlessPointer As IntPtr = IntPtr.Zero
For I As Int32 = 1 To 1000
   PointlessPointer = System.Runtime.InteropServices.Marshal.StringToBSTR("Dameon")
Next
Rory is offline   Reply With Quote
Old Dec 22nd, 2005, 11:32 PM   #13
Dameon
Troll
 
Dameon's Avatar
 
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4 Dameon is on a distinguished road
Exhuming the corpse of a long dead thread, are we Rory?
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270
Dameon is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:01 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC