I want to know if it’s possible to implement a Do Loop with an extension function.
Here’s my non-working code:
<System.Runtime.CompilerServices.Extension()> _
Public Sub DoUntil(condition As Func(Of Boolean), action As Action)
Do Until condition
action()
Loop
End Sub
So it could be called like:
DoUntil(Function() Finished = True, Sub()
x = x + 1
If IsPrime(x) Then
Finished = True
)
But I get error: Value of type ‘System.Func(Of Boolean)’ cannot be converted to ‘Boolean’
Thanks.
Assuming you already have this (C#, sorry, I’m not very proficient with VB):
Getting the count is easy:
This returns
4(Foo1,foo7,Foo14andFoo).