I have just started learning the Lambda expression.
Is it possible to further simplify the following code:
Customer customer = customer FirstOther Default (C => C ID == 3); If (customer == blank) {customer = new customer () {first name = "ben", last name = "foster", id = 3}; Customers.Add (Customer); } // Clients do something with the customer. Creteprophile ();
Basically I want to know whether an object exists in the collection or not. If I do not want to make it, add it to the collection and use it later.
thanks Ben
In writing, it is necessary to be clear and legible Does not seem to be more than that. Lambda and operator ?
There are definitely methods of grabbing to misuse it, to write it in a line, but ultimately they only serve to obscure the code.
No comments:
Post a Comment