问题描述
我使用 联系人Picker和ContactPickerUI创建了一个应用程序。我添加了这样的联系人字段:
I have created one application using contact Picker and ContactPickerUI. i have added the contact fields like this:
private void AddSampleContact(ContactModel addedContact)
{
Contact newContact = new Contact();
IList<IContactField> contactfields = newContact.Fields;
newContact.Name = addedContact.Name;
string email = addedContact.Email;
string phonono = addedContact.PhoneNo;
ContactLocationField location = new ContactLocationField(addedContact.Location, ContactFieldCategory.Home);
contactfields.Add(new ContactField(email, ContactFieldType.Email, ContactFieldCategory.None));
contactfields.Add(new ContactField(phonono, ContactFieldType.PhoneNumber, ContactFieldCategory.Work));
contactfields.Add(location);
AddContactResult addResult = contactPickerUI.AddContact(addedContact.Id, newContact);
}
这里正在运作 perfect.i dun知道怎么样?看来contactfields是指向我的 newContact.Fields.is它如果不是那么它如何将字段分配给我的newContact对象,因为我将字段添加到contactfields而不是newContact.Fields。
Aruna Bhayani
here this is working perfectly.i dun know how??it seems that contactfields is pointer to my newContact.Fields.is it so??if not then how does it assign the fields to my newContact object as i am addeing the fields to contactfields not to newContact.Fields.
Aruna Bhayani
推荐答案
IList<IContactField> contactfields = newContact.Fields;
contactfields和newContact.Fiedls是相同的列表,引用是相同的。
the contactfields and newContact.Fiedls are the same list, the reference is the same.
如果您更改了联系人字段,则更改newContact.Fiedls。
If you change the contactfields you are change the newContact.Fiedls.
但如果不想要,您可以尝试这样做:
but if don´t want you can try this:
IList<IContactField> contactfields = newContact.Fields.ToList();
使用System.Linq。
using System.Linq.
因为你想要一个包含这些项目的新列表,对吗?尽量清楚......
Because you want a new list with that items, right? Try to be clear...
这篇关于如何在winRT中使用contactPicker中的联系对象添加字段(使用C#)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!