Probably MyList is not a list. Check if ToList.ForEach works:
With MyList
.ToList.ForEach(Sub(c) . . . )
End With
It assumes that MyList consists of objects (not structures).
But also clarify why MyList is not a List.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hallo,
I had a following line , it worked few days ago and then i updated my ClosedXML and it gives me this error "For Each is not a member if IEnumerable"
Anyidea to correct this error?
With MyList
.ForEach.(Sub(c) If c.TSpec1 > 0 AndAlso Not c.UoM1.Equals("-") Then c.TSpec1 = Math.Round(UnitValue(CDbl(c.TSpec1), c.UoM1), 3, MidpointRounding.AwayFromZero)))
End With
Thanks
Probably MyList is not a list. Check if ToList.ForEach works:
With MyList
.ToList.ForEach(Sub(c) . . . )
End With
It assumes that MyList consists of objects (not structures).
But also clarify why MyList is not a List.
sorry for the confusion, I meant to say "MyList" is not a real list .. it is a list with other names. The code worked previously
Hi @Hobbyist_programmer ,
In order to avoid the exception, you can add the following extension method to your project.
Module IEnumerableExtensions
<Extension()>
Public Sub ForEach(Of T)(ByVal source As IEnumerable(Of T), ByVal action As Action(Of T))
For Each element As T In source
action(element)
Next
End Sub
End Module
Hope it could be helpful.
Best Regards,
Xingyu Zhao
*
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.