View Single Post
Old Dec 8th, 2005, 11: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