【发布时间】:2018-12-08 18:30:03
【问题描述】:
我正在尝试创建一个递归函数来返回 IEnmerable(Of Control) 中控件的所有后代。我创建了一个返回IEnumerable(Of Control) 的函数并使用了Yield:
Public Function GetControls(C As Control) As IEnumerable(Of Control)
For Each Child As Control In C.Controls
Yield Child
For Each GrandChild In GetControls(Child)
Yield GrandChild
Next
Next
End Function
但是我有一个编译时错误:
错误 BC30800,方法参数必须用括号括起来。
我尝试像函数 Yield(Child) 或 Yield Return Child 或 Return Yield Child 一样使用它,但仍然出现错误。
通过在 google 或 bing 中搜索错误消息,我找不到与该问题相关的任何内容。我该如何解决这个问题?
【问题讨论】:
-
您使用的是哪个版本的 VB/.NET/Visual Studio?
-
@StevenDoggart 我正在使用 Visual Studio 2017 .NET 4.6.2
标签: .net vb.net ienumerable yield