问题
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