Lambda expressions and the Action<Object> delegate, further question #3

I'm sorry, but I still don't get this.

"Lambda expressions are, in effect, anonymous methods that take one argument, and return a value.
In the case of the Action<T> delegate the return value is ignored."

In my previous question, it was stated:

argument passed into the anonymous method is "x" (or the function pointer to the Debug.Indent method):
ICommand _indentCommand = new SimpleDelegateCommand( x => Debug.Indent() );

What is the return value that is being ignored by the Action<T> delegate?
Does the whole of the lambda expression represent the Action<T> required as the argument for the SimpleDelegateCommand or is it just the left hand side or right hand side?

quentinAAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lazyberezovskyCommented:
Let's go step by step::
ICommand _indentCommand = new SimpleDelegateCommand( x => Debug.Indent() );
equals to
ICommand _indentCommand = new SimpleDelegateCommand(delegate(object x) { Debug.Indent(); } );
See that signature? delegate void Name(object x)
Debug.Indent() is not a signature of delegate - it is delegate's body.

Going further (replacing anonymous method with named method):
ICommand _indentCommand = new SimpleDelegateCommand(DoSomething);

private void DoSomething(object x)
{
    // paremeter x simply not used
    Debug.Indent();
}

Any questions?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lazyberezovskyCommented:
And answers to your questions:
1) What is the return value that is being ignored by the Action<T> delegate?
    definition of Action<T>:
    public delegate void Action<T>(T obj);
    It means "any method (either named or anonymous) that excepts one parameter and returns void". There is no return value.

2) Does the whole of the lambda expression represent the Action<T> required as the argument for the SimpleDelegateCommand or is it just the left hand side or right hand side?
   Yes, it all required as parameter.
   See http://msdn.microsoft.com/en-us/library/bb397687.aspx
 

   
   
0
quentinAAuthor Commented:
Thanks. I finally understand it!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.