/// <summary> /// Formats the specified string as a phone number, varying according to the culture. /// </summary> /// <param name="phone">The phone number to format.</param> /// <returns></returns> public string FormatPhone(string phone) { if (string.IsNullOrEmpty(phone)) { return(string.Empty); } if (phone.Length <= 3) { return(phone); } if (phone.IndexOfAny(new[] { '(', '-', '.' }) != -1) { return(phone); } var formatter = new PhoneFormatter(); return(formatter.Format(phone)); }
/// <summary> /// Formats the specified string as a phone number, varying according to the culture. /// </summary> /// <param name="phone">The phone number to format.</param> /// <returns></returns> public string FormatPhone(string phone) { if (string.IsNullOrEmpty(phone)) { return string.Empty; } if (phone.Length <= 3) { return phone; } if (phone.IndexOfAny(new char[] {'(', '-', '.'}) != -1) { return phone; } PhoneFormatter formatter = new PhoneFormatter(); return formatter.Format(phone); }
/// <summary>Convert the number to a formatted string.</summary> /// <returns>A formatted phone number</returns> public override string ToString() { return(formatter.Format(Number)); }