gpt4 book ai didi

vb.net - 在 VB.NET 中模拟 For Each 循环中的 'Where' 子句

转载 作者:行者123 更新时间:2023-12-03 00:36:23 25 4
gpt4 key购买 nike

VB.NET 中的 For Each 循环中是否可以有类似于 SQL“WHERE”子句的内容?即:

 FOR EACH event IN events 
'WHERE eventdate=getdate
NEXT

最佳答案

在 LINQ 中它将是(.NET 3.5 或更高版本)

For Each event in events.Where(Function(x) x.eventdate = getdate)
'Process event
Next

和非 Linq(.Net 2.0 或更低版本)

For Each event in events
If event.eventdate = getdate Then
'Process event
End If
Next

关于vb.net - 在 VB.NET 中模拟 For Each 循环中的 'Where' 子句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1303317/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com