How to get friends that are in a Contact List?

拜拜、爱过 提交于 2019-12-14 03:59:01

问题


I know that I can get all my contacts with Skype.Friends. However I want to get only contacts that are in a specific Contact List.

How can I do it?


回答1:


Try this:

    private void button1_Click(object sender, EventArgs e)
    {
        ArrayList UserList = new ArrayList();
        var SkypeClient = new SKYPE4COMLib.Skype();
        foreach(SKYPE4COMLib.Group Group in SkypeClient.CustomGroups)
        {
                if (Group.DisplayName == "<specify the usergroup name here>")
                {
                    foreach (SKYPE4COMLib.User User in Group.Users)
                    {
                        //Adds the usernames from the specified group in the list.
                        UserList.Add(User.Handle);
                    }
                }
        }

        //Writing the list in a label
        string s = "";
        foreach(string str in UserList)
        {
            s = s + str + Environment.NewLine;
        }
        label1.Text = s;
    }

Oh, and write "using System.Collections;" above the namespace.




回答2:


Linq version of @Visual Vincent's code:

var users = cmd.Skype.CustomGroups.OfType<SKYPE4COMLib.Group>()
    .Where(o => o.DisplayName == "GroupName")
    .SelectMany(o => o.Users.OfType<SKYPE4COMLib.User>());


来源:https://stackoverflow.com/questions/24085275/how-to-get-friends-that-are-in-a-contact-list

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!