.net - Why does System.IO.Directory.GetFiles does not have a List(Of String) return overload? -


i have found overloads return array of strings. there specific reason why there no list(of string)?

i have write

dim nnewstringarray() string redim nnewstringarray(0) nnewstringarray = system.io.directory.getfiles(uinitdir) 

instead of being able write

dim nnewlistofstring new list(of string) = system.io.directory.getfiles(uinitdir) 

i feel redim bit old school.

i can think of 3 reasons (in no particular order):

  1. when method developed there no generics, , no list<t>. string[] best strongly-typed option available @ time.

  2. you can't overload methods return type, have either called getlistoffiles() (bad) or breaking change (very bad)

  3. it's easy do:

    dim nnewlistofstring new list(of string) (system.io.directory.getfiles(uinitdir)) 

plus don't need redim array mentioned in comments question. can do:

dim nnewstringarray() string nnewstringarray = system.io.directory.getfiles(uinitdir) 

or just

dim nnewstringarray() string = system.io.directory.getfiles(uinitdir) 

if prefer. reason turn results list if going add items it. pretty else can done array.


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -