Reputation: 5090
If I have the following anonymous type List defined:
var list = new[] {
new { guid = "f501fbb2-c724-49ef-b7d5-954d7e9329a3", url = "~/Home" },
new { guid = "37df9c3e-f816-4ef9-9023-5f26295feffa", url = "~/Contact" }
}.ToList();
How do I perform a List.ForEach(delegate) on the list? I keep getting a AnonymousType issue: "Argument 1: cannot convert from 'anonymous method' to 'System.Action.'"
(Code tried)
list.ForEach(
delegate(var item) {
// Some function here
}
);
Upvotes: 2
Views: 5530
Reputation: 190941
Try using a lambda expression instead.
list.ForEach(item => /* magic */);
Upvotes: 11