how to format phone number in asp.net using c#

in this web programming tutorial you will learn that how we can format a phone number in US phone format in asp.net using c# compute programming language.

place this code in your aspx.cs file where ever your require to format the phone number.

string homePhone1 = "(" + homePhone.Substring(0, 3) + ")";
                            string homePhone2 = " " + homePhone.Substring(3, 3);
                            string homePhone3 = "-" + homePhone.Substring(6, homePhone.Length - 6);
                            homeFormatted = homePhone1 + homePhone2 + homePhone3;
                            phone_lbl.Text = homeFormatted;

Admin

A Software Engineer, Social Media Marketing Expert, writer,

Post a Comment

Previous Post Next Post