User Tools

Site Tools


lambda_codeblock_anonymous

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

lambda_codeblock_anonymous [2018/01/30 06:09]
wolfgangriedmann created
lambda_codeblock_anonymous [2018/01/30 06:10] (current)
wolfgangriedmann
Line 20: Line 20:
 Some examples of this in use: Some examples of this in use:
 <code>FUNCTION TestAnonymous() AS VOID <code>FUNCTION TestAnonymous() AS VOID
-    LOCAL oForm AS Form +  LOCAL oForm AS Form 
-    oForm := Form{} +  oForm := Form{} 
-    // Anonymous method expression with 2 statements. Note that the  +  // Anonymous method expression with 2 statements. Note that the  
-    // first statement must appear on the line following the opening Curly  +  // first statement must appear on the line following the opening Curly  
-    // and the closing curly must be on a separate line after the statements +  // and the closing curly must be on a separate line after the statements 
-    // (because the statement list 'eats' the end of lines) +  // (because the statement list 'eats' the end of lines) 
-    oForm:Click += DELEGATE(o AS System.Object, e AS System.EventArgs ) { +  oForm:Click += DELEGATE(o AS System.Object, e AS System.EventArgs ) { 
                         System.Windows.Forms.MessageBox.Show("Click 1!"                           System.Windows.Forms.MessageBox.Show("Click 1!"  
                         System.Windows.Forms.MessageBox.Show("Click 2!")                           System.Windows.Forms.MessageBox.Show("Click 2!")  
                    }                      }  
-    // Lambda Expression with untyped parameters and single expression +  // Lambda Expression with untyped parameters and single expression 
-    oForm:Click += { o,e => System.Windows.Forms.MessageBox.Show("Lamda Untyped!") }  +  oForm:Click += { o,e => System.Windows.Forms.MessageBox.Show("Lamda Untyped!") }  
  
-    // Lambda Expression with untyped parameters and single expression. +  // Lambda Expression with untyped parameters and single expression. 
-    // For readability here split over 2 lines with a semicolon that indicates  +  // For readability here split over 2 lines with a semicolon that indicates  
-    // that the statement is continued on the next line +  // that the statement is continued on the next line 
-    oForm:Click += { o as Object,e as EventArgs ; +  oForm:Click += { o as Object,e as EventArgs ; 
                      => System.Windows.Forms.MessageBox.Show("Lamda Typed!") }                        => System.Windows.Forms.MessageBox.Show("Lamda Typed!") }  
  
-    oForm:ShowDialog() +  oForm:ShowDialog() 
-    RETURN<code>+  RETURN</code>
          
 Source: [[https://www.xsharp.info/forum/private-product/306-codeblock-syntax-and-lambda-expressions?start=15#1967|Codeblock syntax and Lambda expressions - X# Forum post by Robert v.d.Hulst]] Source: [[https://www.xsharp.info/forum/private-product/306-codeblock-syntax-and-lambda-expressions?start=15#1967|Codeblock syntax and Lambda expressions - X# Forum post by Robert v.d.Hulst]]
  
  
lambda_codeblock_anonymous.txt · Last modified: 2018/01/30 06:10 by wolfgangriedmann