Dear Sir,
I'm Trying to convert from c# to vb.net.
But I have an error "Error BC30205 End of statement expected"
Please Guide me
Thanks
internal static class Extensions
{
/// <summary>
/// Provides access to all controls on a form.
/// </summary>
/// <remarks>
/// See wrapper below <see cref="TextBoxList"/>
/// </remarks>
public static IEnumerable<T> Descendants<T>(this Control control) where T : class
{
foreach (Control child in control.Controls)
{
if (child is T thisControl)
{
yield return (T)thisControl;
}
if (child.HasChildren)
{
foreach (T descendant in Descendants<T>(child))
{
yield return descendant;
}
}
}
}
}
after convert to vb.net
Friend Module Extensions
''' <summary>
''' Provides access to all controls on a form.
''' </summary>
''' <remarks>
''' See wrapper below <see cref="TextBoxList"/>
''' </remarks>
<System.Runtime.CompilerServices.Extension> _
Public Iterator Function Descendants(Of T As Class)(ByVal control As Control) As IEnumerable(Of T)
For Each child As Control In control.Controls
Dim tempVar As Boolean = TypeOf child Is T
Dim thisControl As T = If(tempVar, CType(child, T), Nothing)
If tempVar Then
'error below line code "Error BC30205 End of statement expected"
Yield (T)thisControl
End If
If child.HasChildren Then
For Each descendant As T In Descendants(Of T)(child)
Yield descendant
Next descendant
End If
Next child
End Function
End Module