本文整理匯總了C#中PhoneNumbers.PhoneNumber.Clone方法的典型用法代碼示例。如果您正苦於以下問題:C# PhoneNumber.Clone方法的具體用法?C# PhoneNumber.Clone怎麽用?C# PhoneNumber.Clone使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PhoneNumbers.PhoneNumber
的用法示例。
在下文中一共展示了PhoneNumber.Clone方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: AreEqual
private static bool AreEqual(PhoneNumber.Builder p1, PhoneNumber.Builder p2)
{
return p1.Clone().Build().Equals(p2.Clone().Build());
}
示例2: TruncateTooLongNumber
/**
* Attempts to extract a valid number from a phone number that is too long to be valid, and resets
* the PhoneNumber object passed in to that valid version. If no valid number could be extracted,
* the PhoneNumber object passed in will not be modified.
* @param number a PhoneNumber object which contains a number that is too long to be valid.
* @return true if a valid phone number can be successfully extracted.
*/
public bool TruncateTooLongNumber(PhoneNumber.Builder number)
{
if (IsValidNumber(number.Clone().Build()))
return true;
PhoneNumber copy = null;
ulong nationalNumber = number.NationalNumber;
do
{
nationalNumber /= 10;
PhoneNumber.Builder numberCopy = number.Clone();
numberCopy.SetNationalNumber(nationalNumber);
copy = numberCopy.Build();
if (IsPossibleNumberWithReason(copy) == ValidationResult.TOO_SHORT ||
nationalNumber == 0)
return false;
}
while (!IsValidNumber(copy));
number.SetNationalNumber(nationalNumber);
return true;
}