There is a class diagram
public class Particip { public string Name { get; set; } public List<Result> Results { get; set; } = new List<Result>(); } public class Result { public int SubjectCode { get; set; } //1-русский язык, 2-математика, 3-физика public int Mark5 { get; set; } //отметка по 5-ти бальной шкале } class Program { static void Main(string[] args) { var participResults1 = new List<Result> { new Result { SubjectCode = 1, Mark5 = 2 }, new Result { SubjectCode = 2, Mark5 = 2 }, new Result { SubjectCode = 3, Mark5 = 3 } }; var participResults2 = new List<Result> { new Result { SubjectCode = 1, Mark5 = 3 }, new Result { SubjectCode = 2, Mark5 = 3 }, new Result { SubjectCode = 3, Mark5 = 2 } }; var particips = new List<Particip> { new Particip { Name = "Иван", Results = participResults1 }, new Particip { Name = "Андрей", Results = participResults2 } }; Console.ReadLine(); } } Here participants of testing and their results in subjects are described.
Question
- It is necessary to find out: are there any
participsin theparticipscollection who have only 2Mark5 == 2on one subject (Mark5 == 2). - And change that number to 3.
Those. In this example, this participant is Andrew - he has only one deuce (in physics) and we need to update the particips collection with the editing of this deuce by three.
Attempts
I swear I tried various versions of the Any , Where and Count methods and nothing happened. I did not try GroupBy - because of the nesting of the collection, I didn’t know which side would be suitable.