Supose I have a class representing a friend and another one representing pairs of best friends and a list of pairs of best friends and want to know each friend that is indirectly related to each one's best friend, as follows:
class Friend
{
string Name;
}
class BestFriends
{
Friend NameFriend1;
Friend NameFriend2;
}
List<BestFriends> ListOfBestFriends = new List<BestFriends>();
Supose I have the BestFriends pairs as follows:
- Adam and Brian;
- Brian and Chris;
- Chris and Daniel;
- Eddie and Ian;
- Brian and John.
I want to create a method that returns a list of all friends indirectly related to one specific friend. For example: if I want all indirect friends of Brian, the method would return { Adam, Chris, Daniel, John }.
List<Friend> IndirectFriends (Friend friendToHasItsIndirectFriendsFound, List<BestFriends> bestFriendsPairs)
{
...
}
How could I do that?
Also consider adding an Id to the Friend class and use that to compare instead of names