是否可以在不指定大小的情况下创建空数组?
例如,我创建了:
String[] a = new String[5];
Run Code Online (Sandbox Code Playgroud)
我们可以创建没有大小的上面的字符串数组吗?
private string[] ColeccionDeCortes(string Path)
{
DirectoryInfo X = new DirectoryInfo(Path);
FileInfo[] listaDeArchivos = X.GetFiles();
string[] Coleccion;
foreach (FileInfo FI in listaDeArchivos)
{
//Add the FI.Name to the Coleccion[] array,
}
return Coleccion;
}
Run Code Online (Sandbox Code Playgroud)
我想将其转换FI.Name为字符串,然后将其添加到我的数组中.我怎样才能做到这一点?