User Tools

Site Tools


codesamples:delegateswork

How delegates work

function Start( ) as void
	
DelegatesTester{}:Check()
	
return         

delegate IntDelegate( nParm as int ) as void                          

class DelegatesTester             
	
constructor()
	
return
	
method Check() as void
local oDelegate as IntDelegate
	
oDelegate := Execute1
oDelegate:Invoke( 123 )
oDelegate:Invoke( 456 )
oDelegate := Execute2
oDelegate:Invoke( 123 )
oDelegate:Invoke( 456 )    
// oDelegate:Invoke( "Hi" )    
oDelegate := Execute3
	
oDelegate( 789 )
	
return	
	
method Execute1( nParm as int ) as void
	
System.Console.WriteLine( "From Execute1: " + nParm:ToString() )
	
return	
	
method Execute2( nParm as int ) as void
	
System.Console.WriteLine( "From Execute2: " + nParm:ToString() )
	
return	

method Execute3( cParm as string ) as void
	
System.Console.WriteLine( "From Execute3: " + cParm )
	
return	
	
end class
codesamples/delegateswork.txt · Last modified: 2018/05/23 09:45 by wolfgangriedmann