コード例 #1
0
    private string FormatPhoneBasedOnLocation(string phoneNo, string location)
    {
        string _formatedPhoneNo = "";

        phoneNo = RemovePhoneNumberFormat(phoneNo);
        if (phoneNo != "")
        {
            phoneFmt         = employee.GetHireLocPhoneFormat(ddlHireLocation.SelectedValue);
            _formatedPhoneNo = String.Format("{0:" + phoneFmt + "}", Double.Parse(phoneNo));

            // For future use
            //string _hashCount = phoneFmt.Replace("(", "");
            //_hashCount = _hashCount.Replace(")", "");
            //_hashCount = _hashCount.Replace("-", "");
            //_hashCount = _hashCount.Replace(" ", "");

            //if (_hashCount.Length == phoneNo.Length)
            //    _formatedPhoneNo = String.Format("{0:" + phoneFmt + "}", Double.Parse(phoneNo));
            //else
            //    _formatedPhoneNo = "";
        }
        return(_formatedPhoneNo);
    }