c# 4.0 - C# 4.0 Anonymous Functions -


how do following shown in javascript in c# 4.0:

var output = dosomething(variable, function() {     // anonymous function code }); 

i'm sure i've seen somewhere before cannot find examples.

you'll want in lambda expressions though it's not quite javascript because c# works quite bit differently. may want check out delegates.

example code:

namespace test {     class tests {         delegate string mydelegate();          public void main(string[] args) {             var output = dosomething("test1", () => { return "test2";} );         }          public string dosomething(string test, mydelegate d) {             return test + d();         }     } } 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -