-
Aug 27th, 2013, 04:45 AM
#1
Thread Starter
Member
[RESOLVED] Lamda function at PUBLIC Declaration
how to declare Lamda function at PUBLIC with in a class
error code
PHP Code:
Public Class ExClass
Dim _duplicatedocumentJSC As Func(Of Boolean) Public Function Getvalue () as boolean _duplicatedocumentJSC = Function(_newName$) As Boolean ' Getting Error here : Nested function does not have a signature that is compatible with delegate '<delegatename>'
End Function End Function
End Class
Below code is working fine
PHP Code:
Public Class ExClass
Dim _duplicatedocumentJSC As Func(Of Boolean) Public Function Getvalue () as boolean _duplicatedocumentJSC = Function() As Boolean End Function End Function End Class
Last edited by dhilip81; Aug 27th, 2013 at 04:52 AM.
-
Aug 27th, 2013, 06:29 AM
#2
Re: Lamda function at PUBLIC Declaration
You declared the function signature as parameterless, then tried to create the function with a parameter... so yeah, of course the signatures don't match.
Code:
Dim _duplicatedocumentJSC As Func(Of Boolean)(somename as string)
Public Function Getvalue () as boolean
_duplicatedocumentJSC = Function(_newName$) As Boolean
' Getting Error here :
Nested function does not have a signature that is compatible with delegate '<delegatename>'
End Function
End Function
End Class
-tg
-
Aug 27th, 2013, 07:10 AM
#3
Re: Lamda function at PUBLIC Declaration
Originally Posted by techgnome
You declared the function signature as parameterless, then tried to create the function with a parameter... so yeah, of course the signatures don't match.
Code:
Dim _duplicatedocumentJSC As Func(Of Boolean)(somename as string)
That will not work, the signature is that it takes a string and returns a boolean so it should look like this:
Code:
Private _duplicatedocumentJSC As Func(Of String, Boolean)
-
Aug 27th, 2013, 07:33 AM
#4
Re: Lamda function at PUBLIC Declaration
Ugh... yeah. sorry... I had Generics on the brain when I wrote that and no chance to try it out.
-tg
-
Aug 28th, 2013, 03:23 AM
#5
Thread Starter
Member
Re: Lamda function at PUBLIC Declaration
yes
PHP Code:
Private _duplicatedocumentJSC As Func(Of String, Boolean)
it's working fine sir
thank you techgnome n Joacim Andersson.....
but i troubled the another one ...
PHP Code:
Public Class ExClass
Dim _duplicatedocumentJSC As Func(Of String, Boolean) Public Function Getvalue () as boolean _duplicatedocumentJSC = Function(Byval _newname$ , ByRef getlayerSize as SizeF) As Boolean ' Getting Error here : Nested function does not have a signature that is compatible with delegate '<delegatename>'
End Function End Function End Class
m using ByRef
-
Aug 28th, 2013, 04:01 AM
#6
Re: Lamda function at PUBLIC Declaration
You can't use the generic delegate Func(Of ...) if one of the arguments is to be passed ByRef you need to declare your own delegate for that.
Code:
Delegate Function MyFunc(s As String, ByRef sf As SizeF) As Boolean
Private _duplicatedocumentJSC As MyFunc
-
Oct 16th, 2017, 06:42 AM
#7
Thread Starter
Member
Re: [RESOLVED] Lamda function at PUBLIC Declaration
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|