I am trying to understand the Lambda expression.
I found that it does make anonymous delegates a little clearer.
For example I have the following where I am setting up SqlParameters:
In the first .Find expression I am using an anonymous delegate which is a little more complicated. But the 2nd .Find uses a Lambda. Both work but the Lambda is simpler.
What I don't understand is what the "c" is? I assume it is just saying that c is an SqlParameter (without the delegate expression).
I assume this is like saying:
Using "c" as an SqlParameter, find an instance of an SqlParameter in our list where c.Parameter name is equal to "@Client".
Is it faster than the delegate?
Thanks,
Tom
I found that it does make anonymous delegates a little clearer.
For example I have the following where I am setting up SqlParameters:
Code:
List<SqlParameter> parms = new List<SqlParameter>();
parms.Add(database.SetParameter("@Friend",SqlDbType.Int,2));
parms.Add(database.SetParameter("@Client",SqlDbType.VarChar,50,"Joes bar and grill"));
parms.Find(delegate(SqlParameter sp) { return sp.ParameterName == "@Client"; }).Value = "Test 1";
parms.Find(c => c.ParameterName == "@Client").Value = "Test 2";
In the first .Find expression I am using an anonymous delegate which is a little more complicated. But the 2nd .Find uses a Lambda. Both work but the Lambda is simpler.
What I don't understand is what the "c" is? I assume it is just saying that c is an SqlParameter (without the delegate expression).
I assume this is like saying:
Using "c" as an SqlParameter, find an instance of an SqlParameter in our list where c.Parameter name is equal to "@Client".
Is it faster than the delegate?
Thanks,
Tom