Comparing lists of GetFriends() and GetFollowers()

Mar 14, 2014 at 6:53 PM
Hello again,

I've come up with a problem that I have tried to solve myself and through asking on StackExchange,

I am trying to compare the list of friends against the list of followers and display the difference, in this case the people who are you following but aren't following you using :
var friends = user.GetFriends(500).ToList();
            var following = user.GetFollowers(500).ToList();
            var result = compareFollowingtoFollowers(friends, following);
            foreach(var res in result)
 private List<T> compareFollowingtoFollowers<T>(List<T> friends, List<T> followers)

            var results = friends.Except(followers).ToList();
            return results;
From what has been explained to me from the StackExchange question

The User class needs to implement IEquatable, because it's seeing the objects returned as the all different objects so it's returning them all.

My question is does Tweetinvi already do this and I'm just being dense again or will I need to (learn to) override the User class from the library and implement IEquatable?

Thank you for reading, I appreciate any help being a self/Internet Based taught person.
Mar 14, 2014 at 7:29 PM
var user = User.GetLoggedUser();
var friends = user.GetFriends();
var followers = user.GetFollowers();

var result = followers.Where(follower => friends.All(friend => follower.Id != friend.Id));
Marked as answer by linvi on 3/14/2014 at 12:00 PM
Mar 14, 2014 at 7:42 PM
Wow thank you, having it wrote that like has made it make a lot more sense to me, I was needlessly over complicating it, thank you for your time.
Mar 14, 2014 at 8:00 PM
You're welcome but please be careful, I have inverted it.
var result = friends.Where(friend=> followers.All(follower => follower.Id != friend.Id));
Mar 14, 2014 at 8:19 PM
Yes I noticed that afterwards and changed it but thank you again, I would've ended up doing the opposite at some point anyway :)