<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4893654290468479361</id><updated>2012-02-04T12:48:55.474-08:00</updated><category term='C#'/><category term='goodies'/><category term='.Net 3.0'/><category term='lambda expression'/><category term='programming'/><title type='text'>Ahmad ABU ARJA</title><subtitle type='html'>Solution Designer {.Net, SQL Server, Azure}
       MCSD, MCTS, MCPD Enterprise</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://abuarja.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4893654290468479361/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://abuarja.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Ahmad ABU ARJA</name><uri>http://www.blogger.com/profile/09153023191192360245</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://bp2.blogger.com/_sJajAbswZ0E/SJW0oudRlVI/AAAAAAAAAAM/9KR6xMrSSbw/S220/n630075444_602150_9656.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>8</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4893654290468479361.post-8863631569515360624</id><published>2009-12-19T13:08:00.000-08:00</published><updated>2009-12-19T13:24:16.067-08:00</updated><title type='text'>make your class provides asynchronous methods by very easy steps</title><content type='html'>&lt;span style="font-size:130%;"&gt;You can provide an asynchronous API via your class in a few easy steps: &lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;declare delegate with signature same as your method that you want to expose it as asynchronous.&lt;/li&gt;&lt;li&gt;declare private instance of the delegate.&lt;/li&gt;&lt;li&gt;wrap BeginInvoke and EndInvoke methods of the delegate.&lt;/li&gt;&lt;/ul&gt; &lt;div style="background: white none repeat scroll 0% 0%; font-family: Courier New; font-size: 10pt; color: black; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;"&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    1&lt;/span&gt;  &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;TestClass&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    2&lt;/span&gt;     {&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    3&lt;/span&gt;         &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;delegate&lt;/span&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;sayHelloDelegate&lt;/span&gt;(&lt;span style="color: blue;"&gt;string&lt;/span&gt; name);&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    4&lt;/span&gt;         &lt;span style="color: rgb(43, 145, 175);"&gt;sayHelloDelegate&lt;/span&gt; sayHello;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    5&lt;/span&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    6&lt;/span&gt;         &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt; SayHello(&lt;span style="color: blue;"&gt;string&lt;/span&gt; name)&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    7&lt;/span&gt;         {&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    8&lt;/span&gt;             &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt;.Format(&lt;span style="color: rgb(163, 21, 21);"&gt;"Hello {0}"&lt;/span&gt;, name);&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    9&lt;/span&gt;         }&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   10&lt;/span&gt;         &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;IAsyncResult&lt;/span&gt; BeginSayHello(&lt;span style="color: blue;"&gt;string&lt;/span&gt; name, &lt;span style="color: rgb(43, 145, 175);"&gt;AsyncCallback&lt;/span&gt; callback, &lt;span style="color: blue;"&gt;object&lt;/span&gt; @object)&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   11&lt;/span&gt;         {&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   12&lt;/span&gt;             sayHello = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;sayHelloDelegate&lt;/span&gt;(SayHello);&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   13&lt;/span&gt;             &lt;span style="color: blue;"&gt;return&lt;/span&gt; sayHello.BeginInvoke(name, callback, @object);&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   14&lt;/span&gt;         }&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   15&lt;/span&gt;         &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt; EndSayHello(&lt;span style="color: rgb(43, 145, 175);"&gt;IAsyncResult&lt;/span&gt; result)&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   16&lt;/span&gt;         {&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   17&lt;/span&gt;             &lt;span style="color: blue;"&gt;return&lt;/span&gt; sayHello.EndInvoke(result);&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   18&lt;/span&gt;         }&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   19&lt;/span&gt;     }&lt;/span&gt;&lt;/p&gt; &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4893654290468479361-8863631569515360624?l=abuarja.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://abuarja.blogspot.com/feeds/8863631569515360624/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4893654290468479361&amp;postID=8863631569515360624' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4893654290468479361/posts/default/8863631569515360624'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4893654290468479361/posts/default/8863631569515360624'/><link rel='alternate' type='text/html' href='http://abuarja.blogspot.com/2009/12/make-your-class-provides-asynchronous.html' title='make your class provides asynchronous methods by very easy steps'/><author><name>Ahmad ABU ARJA</name><uri>http://www.blogger.com/profile/09153023191192360245</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://bp2.blogger.com/_sJajAbswZ0E/SJW0oudRlVI/AAAAAAAAAAM/9KR6xMrSSbw/S220/n630075444_602150_9656.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4893654290468479361.post-312805691726062020</id><published>2009-07-23T00:11:00.000-07:00</published><updated>2009-07-23T00:14:01.204-07:00</updated><title type='text'>Best Practices for Individual Contribution</title><content type='html'>find it at  &lt;a href="http://www.hanselman.com/blog/BestPracticesForIndividualContribution.aspx"&gt;http://www.hanselman.com/blog/BestPracticesForIndividualContribution.aspx&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4893654290468479361-312805691726062020?l=abuarja.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://abuarja.blogspot.com/feeds/312805691726062020/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4893654290468479361&amp;postID=312805691726062020' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4893654290468479361/posts/default/312805691726062020'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4893654290468479361/posts/default/312805691726062020'/><link rel='alternate' type='text/html' href='http://abuarja.blogspot.com/2009/07/best-practices-for-individual.html' title='Best Practices for Individual Contribution'/><author><name>Ahmad ABU ARJA</name><uri>http://www.blogger.com/profile/09153023191192360245</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://bp2.blogger.com/_sJajAbswZ0E/SJW0oudRlVI/AAAAAAAAAAM/9KR6xMrSSbw/S220/n630075444_602150_9656.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4893654290468479361.post-4398454556661140509</id><published>2009-07-15T13:51:00.000-07:00</published><updated>2009-07-15T13:52:29.019-07:00</updated><title type='text'>Top 5 Myths about BPM</title><content type='html'>Top 5 Myths about BPM&lt;br /&gt;Article Source: &lt;a href="http://www.pnmsoft.com/bpm_myths.aspx"&gt;http://www.pnmsoft.com/bpm_myths.aspx&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4893654290468479361-4398454556661140509?l=abuarja.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://abuarja.blogspot.com/feeds/4398454556661140509/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4893654290468479361&amp;postID=4398454556661140509' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4893654290468479361/posts/default/4398454556661140509'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4893654290468479361/posts/default/4398454556661140509'/><link rel='alternate' type='text/html' href='http://abuarja.blogspot.com/2009/07/top-5-myths-about-bpm.html' title='Top 5 Myths about BPM'/><author><name>Ahmad ABU ARJA</name><uri>http://www.blogger.com/profile/09153023191192360245</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://bp2.blogger.com/_sJajAbswZ0E/SJW0oudRlVI/AAAAAAAAAAM/9KR6xMrSSbw/S220/n630075444_602150_9656.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4893654290468479361.post-4828137259760660762</id><published>2009-06-01T11:32:00.000-07:00</published><updated>2009-06-17T11:35:41.285-07:00</updated><title type='text'>introduction to asp.net mvc presentation</title><content type='html'>&lt;a href="http://www.slideshare.net/abuarja/aspnet-mvc-1327313"&gt;http://www.slideshare.net/abuarja/aspnet-mvc-1327313&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4893654290468479361-4828137259760660762?l=abuarja.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://abuarja.blogspot.com/feeds/4828137259760660762/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4893654290468479361&amp;postID=4828137259760660762' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4893654290468479361/posts/default/4828137259760660762'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4893654290468479361/posts/default/4828137259760660762'/><link rel='alternate' type='text/html' href='http://abuarja.blogspot.com/2009/06/introduction-to-aspnet-mvc-presentation.html' title='introduction to asp.net mvc presentation'/><author><name>Ahmad ABU ARJA</name><uri>http://www.blogger.com/profile/09153023191192360245</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://bp2.blogger.com/_sJajAbswZ0E/SJW0oudRlVI/AAAAAAAAAAM/9KR6xMrSSbw/S220/n630075444_602150_9656.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4893654290468479361.post-7269272830856324679</id><published>2009-02-22T00:41:00.000-08:00</published><updated>2009-02-22T00:48:49.412-08:00</updated><title type='text'>javascript for c# programmers</title><content type='html'>great tutorials written by  Julian M Bucknall&lt;br /&gt;&lt;br /&gt;&lt;a href="http://blog.boyet.com/blog/javascriptlessons/"&gt;http://blog.boyet.com/blog/javascriptlessons/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://blog.boyet.com/blog/javascriptlessons/javascript-for-c-programmers-types/"&gt;http://blog.boyet.com/blog/javascriptlessons/javascript-for-c-programmers-types/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://blog.boyet.com/blog/javascriptlessons/javascript-for-c-programmers-object-basics/"&gt;http://blog.boyet.com/blog/javascriptlessons/javascript-for-c-programmers-object-basics/ &lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://blog.boyet.com/blog/javascriptlessons/javascript-for-c-programmers-arrays/"&gt;http://blog.boyet.com/blog/javascriptlessons/javascript-for-c-programmers-arrays/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://blog.boyet.com/blog/javascriptlessons/javascript-for-c-programmers-function-basics-and-scope/"&gt;http://blog.boyet.com/blog/javascriptlessons/javascript-for-c-programmers-function-basics-and-scope/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://blog.boyet.com/blog/javascriptlessons/javascript-for-c-programmers-truth-and-falsity/"&gt;http://blog.boyet.com/blog/javascriptlessons/javascript-for-c-programmers-truth-and-falsity/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://blog.boyet.com/blog/javascriptlessons/javascript-for-c-programmers-void/"&gt;http://blog.boyet.com/blog/javascriptlessons/javascript-for-c-programmers-void/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4893654290468479361-7269272830856324679?l=abuarja.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://abuarja.blogspot.com/feeds/7269272830856324679/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4893654290468479361&amp;postID=7269272830856324679' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4893654290468479361/posts/default/7269272830856324679'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4893654290468479361/posts/default/7269272830856324679'/><link rel='alternate' type='text/html' href='http://abuarja.blogspot.com/2009/02/javascript-for-c-programmers.html' title='javascript for c# programmers'/><author><name>Ahmad ABU ARJA</name><uri>http://www.blogger.com/profile/09153023191192360245</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://bp2.blogger.com/_sJajAbswZ0E/SJW0oudRlVI/AAAAAAAAAAM/9KR6xMrSSbw/S220/n630075444_602150_9656.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4893654290468479361.post-4802483431265336068</id><published>2008-08-10T23:22:00.000-07:00</published><updated>2008-08-21T00:46:01.185-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.Net 3.0'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Automatic Properties</title><content type='html'>Now we can declare properties in single step instead of two steps in previous versions [declare private variable then encapsulate it with properties],&lt;br /&gt;&lt;br /&gt;With c# 3.0 can declare properties directly as following&lt;br /&gt;&lt;br /&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://2.bp.blogspot.com/_sJajAbswZ0E/SJ_it9u1vpI/AAAAAAAAAA4/7c4uKfjM-0U/s320/image+1.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5233150571320819346" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;How it’s work&lt;br /&gt;&lt;br /&gt;In background the compiler generates private variable for you , compiler generate it with same property name between brackets&lt;br /&gt;&lt;br /&gt;In previous example property name is FirstName, then the compiler generates private variable with name &lt;firstname&gt;&lt;br /&gt;&lt;br /&gt;Compiler uses this method to naming variable to prevent conflict with user defined variable because user can’t use the bracket in variable names.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_sJajAbswZ0E/SJ_bnHMJpvI/AAAAAAAAAAw/okUpVAF1fpo/s1600-h/image002.jpg"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://3.bp.blogspot.com/_sJajAbswZ0E/SJ_bnHMJpvI/AAAAAAAAAAw/okUpVAF1fpo/s320/image002.jpg" alt="" id="BLOGGER_PHOTO_ID_5233142757019199218" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/firstname&gt;&lt;/div&gt;&lt;div&gt;&lt;firstname&gt;When we use automatic properties in struct, we must explicitly call default constructor from the constructor we wrote.&lt;br /&gt;&lt;br /&gt;e.g.&lt;br /&gt;          &lt;span style=" Courier New&amp;quot;; font-family:&amp;quot;;font-size:10pt;color:blue;"&gt;public&lt;/span&gt;&lt;span style=" Courier New&amp;quot;;font-family:&amp;quot;;font-size:10pt;"&gt; &lt;span style="color:blue;"&gt;struct&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Person&lt;/span&gt;&lt;/span&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=" Courier New&amp;quot;;font-family:&amp;quot;;font-size:10pt;"&gt;       {&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=" Courier New&amp;quot;;font-family:&amp;quot;;font-size:10pt;"&gt;              &lt;span style="color:blue;"&gt;public&lt;/span&gt; Person(&lt;span style="color:blue;"&gt;string&lt;/span&gt; fname, &lt;span style="color:blue;"&gt;string&lt;/span&gt; lname) &lt;b&gt;&lt;span style="background: yellow none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;:&lt;span style="color:blue;"&gt;this&lt;/span&gt;()&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=" Courier New&amp;quot;;font-family:&amp;quot;;font-size:10pt;"&gt;            {&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=" Courier New&amp;quot;;font-family:&amp;quot;;font-size:10pt;"&gt;                  FirstName = fname;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=" Courier New&amp;quot;;font-family:&amp;quot;;font-size:10pt;"&gt;                  LastName = lname;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=" Courier New&amp;quot;;font-family:&amp;quot;;font-size:10pt;"&gt;            }&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=" Courier New&amp;quot;;font-family:&amp;quot;;font-size:10pt;"&gt;            &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt; FirstName { &lt;span style="color:blue;"&gt;set&lt;/span&gt;; &lt;span style="color:blue;"&gt;get&lt;/span&gt;; }&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=" Courier New&amp;quot;;font-family:&amp;quot;;font-size:10pt;"&gt;            &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt; LastName { &lt;span style="color:blue;"&gt;set&lt;/span&gt;; &lt;span style="color:blue;"&gt;get&lt;/span&gt;; }&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=" line-height: 115%; Courier New&amp;quot;;font-family:&amp;quot;;font-size:10pt;"&gt;       }&lt;/span&gt;&lt;/p&gt;&lt;/firstname&gt;&lt;/div&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");&lt;br /&gt;document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;var pageTracker = _gat._getTracker("UA-5360941-1");&lt;br /&gt;pageTracker._trackPageview();&lt;br /&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4893654290468479361-4802483431265336068?l=abuarja.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://abuarja.blogspot.com/feeds/4802483431265336068/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4893654290468479361&amp;postID=4802483431265336068' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4893654290468479361/posts/default/4802483431265336068'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4893654290468479361/posts/default/4802483431265336068'/><link rel='alternate' type='text/html' href='http://abuarja.blogspot.com/2008/08/now-we-can-declare-properties-in-single.html' title='Automatic Properties'/><author><name>Ahmad ABU ARJA</name><uri>http://www.blogger.com/profile/09153023191192360245</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://bp2.blogger.com/_sJajAbswZ0E/SJW0oudRlVI/AAAAAAAAAAM/9KR6xMrSSbw/S220/n630075444_602150_9656.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_sJajAbswZ0E/SJ_it9u1vpI/AAAAAAAAAA4/7c4uKfjM-0U/s72-c/image+1.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4893654290468479361.post-1124082750355001736</id><published>2008-08-10T22:31:00.000-07:00</published><updated>2008-08-21T00:46:52.939-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.Net 3.0'/><category scheme='http://www.blogger.com/atom/ns#' term='lambda expression'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>lambda expression in C#</title><content type='html'>&lt;div class="Section1"&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="line-height: 115%;"&gt;C# 3.0 has many new features come from functional programming, which make C# 3.0 merging between imperative and functional language to be more powerful and elegant language.&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="line-height: 115%;"&gt;&lt;br /&gt;The Functional Language consider as one of the most popular and the oldest programming paradigm [first functional language appears at 1955] has unique characteristics such as:&lt;/span&gt;&lt;/p&gt;  &lt;ul&gt;&lt;li&gt;&lt;span style="line-height: 115%;"&gt;The program considered as a set of functions. &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="line-height: 115%;"&gt;Functions do not change the program's status, all variables are immutable. &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="line-height: 115%;"&gt;No loops, recursion only :) &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="line-height: 115%;"&gt;and lambda expression. &lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;        &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="line-height: 115%;"&gt;For more information about FP =&gt; "&lt;a href="http://en.wikipedia.org/wiki/Functional_programming"&gt;Functional Programming on Wikipedia&lt;/a&gt;".&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="line-height: 115%;"&gt;Lambda expression is unnamed function replaces anonymous method.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 115%;"&gt;    x =&gt; x * 2; &lt;span style="color:green;"&gt;//lambda expression&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;&lt;br /&gt;The previous statement means that x is a parameter of function, and x * 2 is the function body, we can rewrite this without lambda as the following:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=""&gt;&lt;span style="color:blue;"&gt;int&lt;/span&gt;&lt;/span&gt;&lt;span style=""&gt; func(&lt;span style="color:blue;"&gt;int&lt;/span&gt; x) &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;{ &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;return&lt;/span&gt;&lt;span style=""&gt; x * 2; &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;} &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="line-height: 115%;"&gt;&lt;br /&gt;lambda can accept more than one parameter using parentheses and commas&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 115%;"&gt;    (x, y) =&gt; x * y ;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="line-height: 115%;"&gt;&lt;br /&gt;Can written as&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;&lt;span style="color:blue;"&gt;int&lt;/span&gt;&lt;/span&gt;&lt;span style=""&gt; func (&lt;span style="color:blue;"&gt;int&lt;/span&gt; x, &lt;span style="color:blue;"&gt;int&lt;/span&gt; y) &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;{ &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;return&lt;/span&gt;&lt;span style=""&gt; x * y; &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;} &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="line-height: 115%;"&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="line-height: 115%;"&gt;To use lambda in useful way:&lt;/span&gt;&lt;/p&gt;    &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;class&lt;/span&gt;&lt;span style=""&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Program&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;{&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;    &lt;span style="color:blue;"&gt;delegate&lt;/span&gt; &lt;span style="color:blue;"&gt;int&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Increment2&lt;/span&gt;(&lt;span style="color:blue;"&gt;int&lt;/span&gt; i); &lt;span style="color:green;"&gt;//delegate to call the function that created using lambda &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=""&gt;  &lt;span style="color:blue;"&gt;static&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; Main(&lt;span style="color:blue;"&gt;string&lt;/span&gt;[] args)&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;    {&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;        Increment2 I = x =&gt; x += 2; &lt;span style="color:green;"&gt;// assign lambda expression to delegate instance &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;        &lt;span style="color: rgb(43, 145, 175);"&gt;Console&lt;/span&gt;.WriteLine(I(3)); &lt;span style="color:green;"&gt;// call it and return 5 &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="line-height: 115%;"&gt;    }&lt;/span&gt;&lt;span style="line-height: 115%;"&gt;&lt;br /&gt;&lt;br /&gt;Furthermore, to reduce the code amount we wrote, we can use the generic Func delegate.&lt;br /&gt;Func delegate is a generic delegate to function can takes result type, and up to four parameters.&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=""&gt;delegate&lt;/span&gt;&lt;span style=""&gt; TResult &lt;span style="color: rgb(43, 145, 175);"&gt;Func&lt;/span&gt;();&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;delegate&lt;/span&gt;&lt;span style=""&gt; TResult &lt;span style="color: rgb(43, 145, 175);"&gt;Func&lt;/span&gt;(T1 arg1);&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;delegate&lt;/span&gt;&lt;span style=""&gt; TResult &lt;span style="color: rgb(43, 145, 175);"&gt;Func&lt;/span&gt;(T1 arg1, T2 arg2);&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;delegate&lt;/span&gt;&lt;span style=""&gt; TResult &lt;span style="color: rgb(43, 145, 175);"&gt;Func&lt;/span&gt;(T1 arg1, T2 arg2, T3 arg3);&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;delegate&lt;/span&gt;&lt;span style=""&gt; TResult &lt;span style="color: rgb(43, 145, 175);"&gt;Func&lt;/span&gt;(T1 arg1, T2 arg2, T3 arg3, T4 arg4);&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="line-height: 115%;"&gt;&lt;br /&gt;We can rewrite previous example using Func as the following: &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=""&gt;    Func&lt;/span&gt;&lt;span style=""&gt;&lt;&lt;span style="color:blue;"&gt;int&lt;/span&gt;, &lt;span style="color:blue;"&gt;int&lt;/span&gt;&gt; I = x =&gt; x += 2; &lt;/span&gt;&lt;span style=""&gt;&lt;br /&gt;&lt;br /&gt;Note: the last generic parameter is the result type, and it’s mandatory.&lt;br /&gt;Another generic delegate already exist is Action, Action is delegate to function that does not return a value.&lt;br /&gt;&lt;br /&gt;e.g.&lt;br /&gt;&lt;/span&gt;&lt;span style=""&gt;static&lt;/span&gt;&lt;span style=""&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; Main (&lt;span style="color:blue;"&gt;string&lt;/span&gt; [] args) &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;{ &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.5in; line-height: normal;"&gt;&lt;span style=""&gt;var&lt;/span&gt;&lt;span style=""&gt; Persons = &lt;span style="color:blue;"&gt;new&lt;/span&gt; List { &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.5in; line-height: normal;"&gt;&lt;span style=""&gt;new&lt;/span&gt;&lt;span style=""&gt; Person{FirstName=&lt;span style="color: rgb(163, 21, 21);"&gt;"First"&lt;/span&gt;,lastName=&lt;span style="color: rgb(163, 21, 21);"&gt;"Person"&lt;/span&gt;}, &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.5in; line-height: normal;"&gt;&lt;span style=""&gt;new&lt;/span&gt;&lt;span style=""&gt; Person{FirstName=&lt;span style="color: rgb(163, 21, 21);"&gt;"Second"&lt;/span&gt;,lastName=&lt;span style="color: rgb(163, 21, 21);"&gt;"Person"&lt;/span&gt;}, &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.5in; line-height: normal;"&gt;&lt;span style=""&gt;new&lt;/span&gt;&lt;span style=""&gt; Person{FirstName=&lt;span style="color: rgb(163, 21, 21);"&gt;"Third"&lt;/span&gt;,lastName=&lt;span style="color: rgb(163, 21, 21);"&gt;"Person"&lt;/span&gt;}, &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.5in; line-height: normal;"&gt;&lt;span style=""&gt;new&lt;/span&gt;&lt;span style=""&gt; Person{FirstName=&lt;span style="color: rgb(163, 21, 21);"&gt;"Forth"&lt;/span&gt;,lastName=&lt;span style="color: rgb(163, 21, 21);"&gt;"Person"&lt;/span&gt;}, &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.5in; line-height: normal;"&gt;&lt;span style=""&gt;new&lt;/span&gt;&lt;span style=""&gt; Person{FirstName=&lt;span style="color: rgb(163, 21, 21);"&gt;"Fifth"&lt;/span&gt;,lastName=&lt;span style="color: rgb(163, 21, 21);"&gt;"Person"&lt;/span&gt;}, &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.5in; line-height: normal;"&gt;&lt;span style=""&gt;}; &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.5in; line-height: normal;"&gt;&lt;span style=""&gt;Action&lt;/span&gt;&lt;span style=""&gt; print = person =&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Console&lt;/span&gt;.WriteLine(person); &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.5in; line-height: normal;"&gt;&lt;span style=""&gt;Persons.ForEach(print); &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;}&lt;/span&gt;&lt;span style=""&gt;&lt;br /&gt;&lt;br /&gt;On another side we can use lambda expression as parameter to another method.&lt;br /&gt;&lt;/span&gt;&lt;span style=""&gt;List Names = &lt;span style="color:blue;"&gt;new&lt;/span&gt; List();&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;        Names.Add(&lt;span style="color: rgb(163, 21, 21);"&gt;"Ahmad"&lt;/span&gt;);&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;        Names.Add(&lt;span style="color: rgb(163, 21, 21);"&gt;"Mohammed"&lt;/span&gt;);&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;        Names.Add(&lt;span style="color: rgb(163, 21, 21);"&gt;"Joseph"&lt;/span&gt;);&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;        Names.Add(&lt;span style="color: rgb(163, 21, 21);"&gt;"Adam"&lt;/span&gt;);&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;        &lt;span style="color:blue;"&gt;string&lt;/span&gt; findName = &lt;span style="color: rgb(163, 21, 21);"&gt;"Ahmad"&lt;/span&gt;;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;        &lt;span style="color:blue;"&gt;string&lt;/span&gt; name = Names.Find(str =&gt; str == findName); &lt;span style="color:green;"&gt;//use lambda as a parameter &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;        &lt;span style="color:blue;"&gt;if&lt;/span&gt; (&lt;span style="color:blue;"&gt;string&lt;/span&gt;.IsNullOrEmpty(name))&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="line-height: 115%;"&gt;            &lt;span style="color: rgb(43, 145, 175);"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: rgb(163, 21, 21);"&gt;"not found"&lt;/span&gt;);&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="line-height: 115%;"&gt;&lt;br /&gt;You can replace previous lambda with anonymous method &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 115%;"&gt;    &lt;span style="color: rgb(51, 51, 255);"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style="line-height: 115%;"&gt; name = Names.Find(&lt;span style="color:blue;"&gt;delegate&lt;/span&gt;(&lt;span style="color:blue;"&gt;string&lt;/span&gt; str) { &lt;span style="color:blue;"&gt;return&lt;/span&gt; str == findName; });&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="line-height: 115%;"&gt;&lt;br /&gt;You must notice from previous code that the lambda can access the outer variable  &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="line-height: 115%;"&gt;&lt;br /&gt;&lt;b&gt;Now how can we use recursion using lambda:&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;&lt;br /&gt;To write recursion code, first we shall declare delegate using Func&lt;&gt; and assign it with null value, and assign instance delegate to lambda expression in new statement, we most write lambda recursion in two statement to avoid “&lt;/span&gt;&lt;span style=""&gt;Use of unassigned local variable&lt;/span&gt;&lt;span style=""&gt;” error.&lt;br /&gt;e.g.&lt;br /&gt;&lt;/span&gt;&lt;span style=""&gt;        Func&lt;/span&gt;&lt;span style=""&gt;&lt;&lt;span style="color:blue;"&gt;int&lt;/span&gt;, &lt;span style="color:blue;"&gt;int&lt;/span&gt;&gt; factorial = &lt;span style="color:blue;"&gt;null&lt;/span&gt;;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="line-height: 115%;"&gt;        factorial = Num =&gt; Num == 1 ? Num : factorial(Num - 1);&lt;/span&gt;&lt;span style="line-height: 115%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;lambda statement&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="line-height: 115%;"&gt;&lt;br /&gt;lambda statement similar to lambda expression, but lambda statement use brackets because it‘s contains more than one statement, while lambda expression not.&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; line-height: normal;"&gt;&lt;span style=""&gt;&lt;br /&gt;Func&lt;/span&gt;&lt;span style=""&gt;&lt;&lt;span style="color:blue;"&gt;string&lt;/span&gt;, &lt;span style="color:blue;"&gt;int&lt;/span&gt;, &lt;span style="color:blue;"&gt;string&lt;/span&gt;&gt; lstatement = (Name, Num) =&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;            {&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;                &lt;span style="color:blue;"&gt;                string&lt;/span&gt; tempStr = &lt;span style="color:blue;"&gt;null&lt;/span&gt;;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;                &lt;span style="color:blue;"&gt;                for&lt;/span&gt; (&lt;span style="color:blue;"&gt;int&lt;/span&gt; i = 0; i &lt;&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;                                {&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;                                        tempStr += Name;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;                                }&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;                &lt;span style="color:blue;"&gt;                return&lt;/span&gt; tempStr;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt;                        };&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;    &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="line-height: 115%;"&gt;       &lt;span style="color: rgb(43, 145, 175);"&gt;        Console&lt;/span&gt;.WriteLine(lstatement(&lt;span style="color: rgb(163, 21, 21);"&gt;"Omar"&lt;/span&gt;,5));&lt;/span&gt;&lt;span style="line-height: 115%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Notes:&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="line-height: 115%;"&gt;Lambda expression can be converted to expression tree or to delegate.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="line-height: 115%;"&gt;Lambda statement can convert only to delegate type.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="line-height: 115%;"&gt;Anonymous methods must be explicitly typed their parameters, but lambda infers their types.&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;/div&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");&lt;br /&gt;document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;var pageTracker = _gat._getTracker("UA-5360941-1");&lt;br /&gt;pageTracker._trackPageview();&lt;br /&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4893654290468479361-1124082750355001736?l=abuarja.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://abuarja.blogspot.com/feeds/1124082750355001736/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4893654290468479361&amp;postID=1124082750355001736' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4893654290468479361/posts/default/1124082750355001736'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4893654290468479361/posts/default/1124082750355001736'/><link rel='alternate' type='text/html' href='http://abuarja.blogspot.com/2008/08/c-3.html' title='lambda expression in C#'/><author><name>Ahmad ABU ARJA</name><uri>http://www.blogger.com/profile/09153023191192360245</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://bp2.blogger.com/_sJajAbswZ0E/SJW0oudRlVI/AAAAAAAAAAM/9KR6xMrSSbw/S220/n630075444_602150_9656.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4893654290468479361.post-1357489555296127431</id><published>2008-08-03T22:41:00.000-07:00</published><updated>2008-08-21T00:47:09.440-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='goodies'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>"Hello World" in 200 Programming Language</title><content type='html'>I like programming languages   , I like very much to try new languages other than those I already know , and while browsing the web and found a wonderful web site contains "Hello World" examples written in 200 programming language  WOW .&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.scriptol.org/hello-world-programming-language.php"&gt;http://www.scriptol.org/hello-world-programming-language.php&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");&lt;br /&gt;document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;var pageTracker = _gat._getTracker("UA-5360941-1");&lt;br /&gt;pageTracker._trackPageview();&lt;br /&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4893654290468479361-1357489555296127431?l=abuarja.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://abuarja.blogspot.com/feeds/1357489555296127431/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4893654290468479361&amp;postID=1357489555296127431' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4893654290468479361/posts/default/1357489555296127431'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4893654290468479361/posts/default/1357489555296127431'/><link rel='alternate' type='text/html' href='http://abuarja.blogspot.com/2008/08/hello-world-in-200-programming-language.html' title='&quot;Hello World&quot; in 200 Programming Language'/><author><name>Ahmad ABU ARJA</name><uri>http://www.blogger.com/profile/09153023191192360245</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://bp2.blogger.com/_sJajAbswZ0E/SJW0oudRlVI/AAAAAAAAAAM/9KR6xMrSSbw/S220/n630075444_602150_9656.jpg'/></author><thr:total>0</thr:total></entry></feed>
