class user
{
public string userID { get; set; }
public string groupID { get; set; }
public int individualCredit { get; set; }
public int groupCredit { get; set; }
}
I have a list like this
List<user> listUsers = new List<user>();
I need to do following things and I'm giving what I have tried so far.
I want to group users with same groupID
.
Calculate groupCredit
by adding the individualcredit
s of each member in group and by dividing it by the number of group members.
Finally I want to assign each user with their groupCredit
.
There are groups with three to five members.
Can anyone help me in this? at least give me a sample solved question? I searched but I didn't find anything quite matching with this.
This is my linq so far
var groups = lstUsers.GroupBy(x => x.groupID).Select(g => new {ID=g.Key,count=g.Count() });
Here the thing I don't understand to do is get the group mark (It's calculated adding all group members marks and dividing it by number of group members) and to assign group mark to each member in a group.