delegates - Create a function and call it in one line of C# code -


Can I dynamically create a function and add it (by passing values) into a line of code ?

Explanation: I was looking for some kind that allowed me to become an anonymous function and then it could be called directly. By the way:

  Rep (string AA) {message box. Show (aa); } ("Hello world!");  

Or something like that (I know the above code is not compiled, but I wanted to close something).

new action & lt; Int & gt; (X = & Console.WriteLine (x)) (3);

It is not so readable, but answering your question, you can definitely do it.

Edit: Just you have seen that it has been tagged as # 2, the answer above is 3.5 for the 2.0 it will

  the new verb & lt; Int & gt; (Int (int x) {console. WrightLine (x);}) (3);  

Comments