This may be a question for beginners ...
In my code, I can easily use "where Obj.Feld = String", but using "where Obj.Feld.StartsWith (" a ")" does not work. See the following two functions:
Public Function EntriesByFileName(ByRef Database() As Entry, ByVal Filename As _
String) As IEnumerable(Of Entry)
Dim Result As IEnumerable(Of Entry) = From EntryObject In Database _
Where (EntryObject.FileName = Filename) Select EntryObject
Return Result
End Function
Public Function EntriesLikeFileName(ByRef Database() As Entry, ByVal _
Filename As String) As IEnumerable(Of Entry)
Filename = Filename.ToLower
Dim Result As IEnumerable(Of Entry) = From EntryObject In Database _
Where EntryObject.FileName.StartsWith("a") Select EntryObject
Return Result
End Function
The first function (byFileName) works fine. The second function (LikeFileName) does not work. Using Startswith, I get "Object reference not set to instance of object." What am I doing wrong?
A database is an array of objects, a structure consisting of strings
source
share