.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):
when method developed there no generics, , no
list<t>.string[]best strongly-typed option available @ time.you can't overload methods return type, have either called
getlistoffiles()(bad) or breaking change (very bad)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
Post a Comment