I’m having a problem with this code in the highlighted line(*); getting the error in the heading. Any help would be appreciated as I cant get the solution.
Dim htmlarraylist As New List(Of iTextSharp.text.IElement)
htmlarraylist = *HTMLWorker.ParseToList(New StreamReader(tempFile), New StyleSheet())*
document.Open()
For Each element As iTextSharp.text.IElement In htmlarraylist
document.Add(element)
Next
document.Close()
Right, so it sounds like
ParseToListreturns a non-genericArrayList. The simplest way of fixing that – assuming .NET 3.5 – is probably to useCastandToList:Note how I’ve also change the first statement so it no longer creates an instance of
List(Of T)only to immediately throw it away.That’s assuming you really want it as a
List(Of T). If you don’t mind it just been anArrayList, you can just change the declaration:You’re only iterating over it in the code you’ve shown, after all. (You could equally change the declaration to use
IEnumerable.)