我有3个foreach循环嵌套在一起,这可能是性能问题。有没有办法让它更有效率?
编写示例:
List<User> users;
List<Friend> friends;
foreach(user in users)
{
//Find if a user have a friend
foreach(friend in friends)
{
foreach(userFriend in user.friendList)
{
//find match
if(friend.name.Equals(userFriend.name)){
//do stuff
break;
}
}
}
}