Ok Thanks Jano and James

 

That's very useful to know.

 

Regards Peter Maddin
Applications Development Officer
PathWest Laboratory Medicine WA
Phone : +618 6396 4285 (Monday, Wednesday,Friday)

Phone : +618 9346 4372 (Tuesday, Thursday)
Mobile: 0423 540 825 
E-Mail : [email protected]; [email protected]
The contents of this e-mail transmission outside of the WAGHS network are
intended solely for the named recipient's), may be confidential, and may be
privileged or otherwise protected from disclosure in the public interest.
The use, reproduction, disclosure or distribution of the contents of this
e-mail transmission by any person other than the named recipient(s) is
prohibited. If you are not a named recipient please notify the sender
immediately.

 

 

From: [email protected] [mailto:[email protected]]
On Behalf Of James Chapman-Smith
Sent: Monday, 5 December 2011 8:31 PM
To: ozDotNet
Subject: RE: Learning LINQ novice question

 

Here's a simple example:

 

Action<string, int> write = (n, a) =>

{

       Console.WriteLine("Hi {0}, you are {1} years old.", n, a);

};

 

Now, strictly speaking the parentheses are required for zero and for 2 or
more parameters. They are only optional for single parameters.

 

From: [email protected] [mailto:[email protected]]
On Behalf Of Peter Maddin
Sent: Monday, 5 December 2011 22:54
To: 'ozDotNet'
Subject: RE: Learning LINQ novice question

 

Ok Thanks very much

 

So in this case, the parenthesis, can be removed.

Do you have a simple example where  two (or more parameters are used)?

 

What I hate is when one is trying to learn this stuff, something is just
presented without any explanation in the examples used.

 

Regards Peter Maddin
Applications Development Officer
PathWest Laboratory Medicine WA
Phone : +618 6396 4285 (Monday, Wednesday,Friday)

Phone : +618 9346 4372 (Tuesday, Thursday)
Mobile: 0423 540 825 
E-Mail : [email protected]; [email protected]
The contents of this e-mail transmission outside of the WAGHS network are
intended solely for the named recipient's), may be confidential, and may be
privileged or otherwise protected from disclosure in the public interest.
The use, reproduction, disclosure or distribution of the contents of this
e-mail transmission by any person other than the named recipient(s) is
prohibited. If you are not a named recipient please notify the sender
immediately.

 

 

From: [email protected] [mailto:[email protected]]
On Behalf Of Jano Petras
Sent: Monday, 5 December 2011 8:19 PM
To: ozDotNet
Subject: Re: Learning LINQ novice question

 

Parenthesis are used if there is more than one parameter for lambda
function. Not required for single-parameter lambdas.

On 5 December 2011 13:17, Peter Maddin <[email protected]> wrote:

Am learning linq.

 

I noticed from the examples I using to learn, that I have this

 

 var products = GetProducts()

        .Where((prod) => prod.CategoryID == 2);

 

Why is prod placed inside parenthesis?

 

Sometimes it is, sometimes its not.

 

 var productsDictionary =
        products.ToDictionary(prod => prod.ProductID);
 
I am finding this lack of consistency somewhat confusing.
 
Probably the parenthesis can be eliminated, but why in the first example was
it used?
 
Where is it necessary to use parenthesis and where is it not?
The use of parenthesis was introduced without any explanation. 
 
Sorry for such a basic question.

 

Regards Peter Maddin
Applications Development Officer
PathWest Laboratory Medicine WA
Phone : +618 6396 4285 <tel:%2B618%206396%204285>  (Monday,
Wednesday,Friday)

Phone : +618 9346 4372 <tel:%2B618%209346%204372>  (Tuesday, Thursday)
Mobile: 0423 540 825 
E-Mail : [email protected]; [email protected]
The contents of this e-mail transmission outside of the WAGHS network are
intended solely for the named recipient's), may be confidential, and may be
privileged or otherwise protected from disclosure in the public interest.
The use, reproduction, disclosure or distribution of the contents of this
e-mail transmission by any person other than the named recipient(s) is
prohibited. If you are not a named recipient please notify the sender
immediately.

 

 

 

Reply via email to