本文整理汇总了C#中Contact.GetName方法的典型用法代码示例。如果您正苦于以下问题:C# Contact.GetName方法的具体用法?C# Contact.GetName怎么用?C# Contact.GetName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contact
的用法示例。
在下文中一共展示了Contact.GetName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddContactToContacts
public bool AddContactToContacts(Contact contact, bool rewriteFile)
{
bool added = false;
bool alreadyExists = false;
int insertedIndex = 0;
if (contactsLength == 0)
{
contacts.Insert (0, contact);
added = true;
//savedContacts[0]["name"] = contact.GetName();
//savedContacts[0]["number"] = contact.GetNumber();
}
else
{
for (int i = 0; i < contactsLength; i ++)
{
if (string.Compare(contact.GetName(), contacts[i].GetName()) == 0) //this name already exists
{
Debug.Log ("contact info for " + contact.GetName() + " already exists");
alreadyExists = true;
}
else if (string.Compare(contact.GetName(), contacts[i].GetName()) <= 0 && !added)
{
insertedIndex = i;
contacts.Insert (i, contact);
added = true;
}
}
if (!added && !alreadyExists)
{
insertedIndex = contactsLength;
contacts.Add(contact); //add to end
added = true;
}
}
if (added)
{
contactsLength += 1;
}
if (rewriteFile)
{
JSONArray array = (JSONArray)savedContacts ["contacts"];
for (int i = contactsLength-1; i > insertedIndex; i --) //move all contacts up an index in the array
{
array[i]["name"] = array[i-1]["name"];
array[i]["number"] = array[i-1]["number"];
}
array[insertedIndex]["name"] = contact.GetName(); //add the new contact
array[insertedIndex]["number"] = contact.GetNumber();
savedContacts ["contacts"] = array;
System.IO.File.WriteAllText(fileName, savedContacts.ToString());
}
return added;
}
示例2: CreateMessageForContact
private void CreateMessageForContact(Contact contact)
{
var yoInstance = Instantiate(yoMessagePrefab);
yoInstance.transform.SetParent(yoContainer, false);
yoInstance.Initialize(_app, contact);
_messages[contact.GetName()] = yoInstance;
}