I have the following code (sorry for the VB!) and I'm looking to avoid having to do a For Each loop to initialise the values from a String (ie "10,25,50") collection using Int32.TryParse.
Is there a way to do this? Like a Function(x) lambda kind of thing where it only adds items in the String collection when they pass an Int32.TryParse?
Dim options = ConfigHelper.GetContentValue("NavigationPaging", "PageSizeOptions").Split(CChar(","))
Dim optionsList As List(Of Integer) = New List(Of Integer)() 'Initialise the collection here to avoid the For Each
For Each item As String In options
Dim i As Integer
If Int32.TryParse(item, i) Then
optionsList.Add(i)
End If
Next
Thank you.