The following:
Delegate Function OperationDelegate(ByVal x As Double) As Double
Public Function test(Optional ByRef operation As OperationDelegate = AddressOf DefaultOperation) As Double
Return operation.Invoke(3)
End Function
gives me the error: Constant Expression is required. Addressof DefaultOperation is causing the error using Visual Studio 2013.
I have tried defining DefaultOperation in the two following ways.
Public Function DefaultOperation(ByVal x As Double) As Double
Return x
End Function
Dim DefaultOperation As OperationDelegate = Function(x As Double) As Double
Return x
End Function
In either case it has not worked. This is the ressource I have been using: https://msdn.microsoft.com/en-us/library/bb531253.aspx
Anyways thanks for your time.
A similar questions that I found: