开发者

Generic List extension method ForEach stopped working?

I have a custom list that inherits Generic.List and it has a method for deselecting all of the members named DeselectAll

It has looked like this for a few weeks and has worked fine.

Public Sub DeselectAll()
    MyBase.ForEach(Function(p As Publipostable) p.ModeEnvoiChoisi = Nothing)
End Sub

Today, it stopped working ?!? I reverted to an earlier version using delegates and that works fine...

Public Sub DeselectAll()
    MyBase.ForEach(AddressOf DeselectModeEnvoi)
End Sub

Private Sub DeselectModeEnvoi(ByVal p As IPublipostable)
    p.ModeEnvoiChoisi = Nothing
End Sub

Has anyone seen this behavior? It's in an asp.net 3.5 app.

Just wondering, Sam

Edit: Stopped Working meaning it no longer sets the property p.ModeEnvoiChoisi to Nothing on each item in the list. The DeselectAll method gets called开发者_StackOverflow社区, but all the items retain their previous values...


In .net 3.5 VB doesn't have a way to distinguish between an equality operator vs a set operator since both are "=" and the compiler choses the equality check (weird I know). In .net 4.0 you can use set operators in lambda functions without problems, but in .net 3.5 you can't in VB.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜