本文整理匯總了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;
}