{"id":221,"date":"2016-02-21T16:26:56","date_gmt":"2016-02-21T15:26:56","guid":{"rendered":"http:\/\/www.riedmann.it\/blog\/?p=221"},"modified":"2016-02-21T16:30:27","modified_gmt":"2016-02-21T15:30:27","slug":"delegates-sample","status":"publish","type":"post","link":"https:\/\/blog.riedmann.it\/?p=221","title":{"rendered":"Delegates sample"},"content":{"rendered":"<p>Hi,<\/p>\n<p>when working with X# and Vulcan.NET, I have created this particular sample. It should help understand how delegates work (and that they are immutable):<\/p>\n<blockquote><p>\n#using DelegateSample<\/p>\n<p>begin namespace DelegateSample<\/p>\n<p>public delegate SampleDelegate( cParameter as string ) as void    <\/p>\n<p>function Start( ) as void<br \/>\n&nbsp;&nbsp;local oSample as SampleClass<br \/>\n&nbsp;&nbsp;local oSample2 as Sample2Class<br \/>\n&nbsp;&nbsp;local oDelegate as SampleDelegate<br \/>\n&nbsp;&nbsp;local oDelegate2 as SampleDelegate<\/p>\n<p>&nbsp;&nbsp;System.Console.WriteLine(&#8220;Start SampleDelegate&#8221;)<\/p>\n<p>&nbsp;&nbsp;oSample := SampleClass{}<br \/>\n&nbsp;&nbsp;oSample2 := Sample2Class{}<\/p>\n<p>&nbsp;&nbsp;oDelegate := SampleDelegate{ oSample:Method1 }<br \/>\n&nbsp;&nbsp;oDelegate += oSample:Method2<br \/>\n&nbsp;&nbsp;oDelegate += oSample2:Method3<\/p>\n<p>&nbsp;&nbsp;oDelegate( &#8220;Hi&#8221; )<br \/>\n&nbsp;&nbsp;oDelegate2 := oDelegate<\/p>\n<p>&nbsp;&nbsp;oDelegate -= oSample:Method2<br \/>\n&nbsp;&nbsp;oDelegate -= oSample2:Method3<\/p>\n<p>&nbsp;&nbsp;oDelegate( &#8220;Hott&#8221; )<br \/>\n&nbsp;&nbsp;oDelegate2( &#8220;Hups&#8221; )<\/p>\n<p>&nbsp;&nbsp;return<\/p>\n<p>class SampleClass<\/p>\n<p>&nbsp;&nbsp;constructor()<\/p>\n<p>&nbsp;&nbsp;return<\/p>\n<p>&nbsp;&nbsp;public method Method1( cParameter as string ) as void<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;System.Console.WriteLine( &#8220;method1, parameter &#8221; + cParameter )<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;return\t\t<\/p>\n<p>&nbsp;&nbsp;public method Method2( cParameter as string ) as void<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;System.Console.WriteLine( &#8220;method2, parameter &#8221; + cParameter )<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;return\t\t<\/p>\n<p>end class    <\/p>\n<p>class Sample2Class<\/p>\n<p>&nbsp;&nbsp;public method Method3( cParameter as string ) as void<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;System.Console.WriteLine( &#8220;method3, Sample2Class, parameter &#8221; + cParameter )<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;return<\/p>\n<p>end class\t\t<\/p>\n<p>end namespace\n<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Hi, when working with X# and Vulcan.NET, I have created this particular sample. It should help understand how delegates work (and that they are immutable): #using DelegateSample begin namespace DelegateSample public delegate SampleDelegate( cParameter as string ) as void function Start( ) as void &nbsp;&nbsp;local oSample as SampleClass &nbsp;&nbsp;local oSample2 as Sample2Class &nbsp;&nbsp;local oDelegate as [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,23],"tags":[],"class_list":["post-221","post","type-post","status-publish","format-standard","hentry","category-vulcan-net-programming","category-x-programming"],"_links":{"self":[{"href":"https:\/\/blog.riedmann.it\/index.php?rest_route=\/wp\/v2\/posts\/221","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.riedmann.it\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.riedmann.it\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.riedmann.it\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.riedmann.it\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=221"}],"version-history":[{"count":4,"href":"https:\/\/blog.riedmann.it\/index.php?rest_route=\/wp\/v2\/posts\/221\/revisions"}],"predecessor-version":[{"id":225,"href":"https:\/\/blog.riedmann.it\/index.php?rest_route=\/wp\/v2\/posts\/221\/revisions\/225"}],"wp:attachment":[{"href":"https:\/\/blog.riedmann.it\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=221"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.riedmann.it\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=221"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.riedmann.it\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=221"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}