Tuesday, October 23, 2012

How to define anynomouse function in C# like Javascript?

In Javascript you can define an anynomous function like:
var InJavasript = (
function(){
             return "some value";
})()

In C#: (need specifiy a function type)
var InCSharp = (
(Func<string>)delegate(){
                return "some value";
            })();

http://msdn.microsoft.com/en-us/library/bb549151.aspx

No comments:

Post a Comment