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/