70-483 question 69 discussion

answered

You have a method named GetCustomerIDs that returns a list of integers. Each entry in the
list represents a customer ID that is retrieved from a list named Customers. The Customers
list contains 1,000 rows.
Another developer creates a method named ValidateCustomer that accepts an integer
parameter and returns a Boolean value. ValidateCustomer returns true if the integer
provided references a valid customer. ValidateCustomer can take up to one second to run.
You need to create a method that returns a list of valid customer IDs. The code must
execute in the shortest amount of time.
What should you do? (Develop the solution by selecting and ordering the required code
snippets. You may not need all of the code snippets.)


Created 2 months, 3 weeks ago by pbush25

pbush25

it should be c in customers.AsParallel() where ValidateCustomer(c) select c).ToList();

mirroj

I agree with Pbush25

abc123456789

I also agree, but aside of that please read the following: You need to create a method that returns a list of valid customer IDs the whole method needs to be constructed.

abc123456789

public List<int> GetValidCustomers() { List<int> validCustomers = (from c in customers.AsParallel() where ValidateCustomer(c) select c).ToList(); return validCustomers; }

JasperKent

Who actually comes up with these wrong answers?

cvaldez.issc

I am not agree, with all user answers, the correct one is the same there, because if you try AsParalell when the list is declared, the compiler won't take the filter into runtime, the best is process multithread method after the Linq query is declared (on my opinion)