本文整理汇总了C#中System.Net.PeerToPeer.Collaboration.ContactManager.DeleteContact方法的典型用法代码示例。如果您正苦于以下问题:C# ContactManager.DeleteContact方法的具体用法?C# ContactManager.DeleteContact怎么用?C# ContactManager.DeleteContact使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.PeerToPeer.Collaboration.ContactManager
的用法示例。
在下文中一共展示了ContactManager.DeleteContact方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeleteContact
//Enumerating the contacts and letting the user choose which one to delete.
public static void DeleteContact()
{
PeerContactCollection pcc = null;
string contactToDelete = "";
try
{
pcc = EnumContacts();
if (pcc == null ||
pcc.Count == 0)
{
Console.WriteLine("Contact list is empty -- no such contact exists.");
return;
}
Console.Write("Please enter the nickname of the contact you wish to delete: ");
contactToDelete = Console.ReadLine();
foreach (PeerContact pc in pcc)
{
if (pc.Nickname.Equals(contactToDelete))
{
PeerCollaboration.ContactManager.DeleteContact(pc);
Console.WriteLine("Contact {0} successfully deleted!", contactToDelete);
return;
}
}
Console.WriteLine("Contact {0} could not be found in the contact collection.", contactToDelete);
}
catch (ArgumentNullException argNullEx)
{
Console.WriteLine("The supplied contact is null: {0}", argNullEx.Message);
}
catch (ArgumentException argEx)
{
Console.WriteLine("The supplied contact \"{0}\" could not be found in the Contact Manager: {1}",
contactToDelete, argEx.Message);
}
catch (PeerToPeerException p2pEx)
{
Console.WriteLine("The Peer Collaboration Infrastructure could not delete \"{0}\": {1}",
contactToDelete, p2pEx.Message);
}
catch (Exception ex)
{
Console.WriteLine("Unexpected exception when trying to delete a contact : {0}", ex);
}
return;
}