Create a property list of object, her capacity is depend dynamic to a property int from a class

AnissGharib49

Member
Joined
May 24, 2021
Messages
8
Programming Experience
Beginner
Could someone help me in this issue: i ve a class Tournament, it has a property Int NumberOfRounds and i want to create also another property List<Pool> Pools in the same class, her Capacity will be dinamiclly depend to the other property NumberOfRounds, for example when de defind NumberOfRounds =4 then i would have (4+1) =5 Pools , than mean List<Pool> Pools { get; set} = new List<Pool>(5);
I need help please if somone could help me i ll apreciate it &thankful
 
Yes, just change the setter for your NumberOfRounds property so that each time the value changes, the size of list is changed.

Personally, though, it sounds like Pools should be treated more like an array rather than a List. By exposing a List someone could just go and call Add() or Remove() on it and and mess up the number of rounds to rounds relationship.
 
Back
Top Bottom