I'm developing a library with .NET Framework 4.5.1 with C#.
I have this code:
user.Groups = modelUser.Groups
    .Select(CreateGroup)
    .ToList();
CreateGroup prototype is:
 public Models.Group CreateGroup(Data.Models.Group modelGroup, bool createMembers)
It has two parameters.
How do I have to modify Select to pass the second parameter, createMembers, to CreateGroup?
You are using method group conversion to pass the method CreateGroup as a parameter.
If you use a lambda you can easily use the parameters you want, e.g.
user.Groups = modelUsers.Groups
                        .Select(g => CreateGroup(g, true))
                        .ToList();
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With