Ich habe ein System.Generic.Collections.List (Of MyCustomClass) -Typ-Objekt.Seite eine generische Sammlung ohne Linq
Integer varaibles pagesize und pagenumber, wie kann ich nur eine einzelne Seite von MyCustomClass
Objekte sammeln?
Das ist, was ich habe. Wie kann ich es verbessern?
'my given collection and paging parameters
Dim AllOfMyCustomClassObjects As System.Collections.Generic.List(Of MyCustomClass) = GIVEN
Dim pagesize As Integer = GIVEN
Dim pagenumber As Integer = GIVEN
'collect current page objects
Dim PageObjects As New System.Collections.Generic.List(Of MyCustomClass)
Dim objcount As Integer = 1
For Each obj As MyCustomClass In AllOfMyCustomClassObjects
If objcount > pagesize * (pagenumber - 1) And count <= pagesize * pagenumber Then
PageObjects.Add(obj)
End If
objcount = objcount + 1
Next
'find total page count
Dim totalpages As Integer = CInt(Math.Floor(objcount/pagesize))
If objcount Mod pagesize > 0 Then
totalpages = totalpages + 1
End If