Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 68247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:23:12+00:00 2026-05-10T19:23:12+00:00

If I had a phone number like this string phone = 6365555796; Which I

  • 0

If I had a phone number like this

string phone = '6365555796'; 

Which I store with only numeric characters in my database (as a string), is it possible to output the number like this:

'636-555-5796' 

Similar to how I could if I were using a number:

long phone = 6365555796; string output = phone.ToString('000-000-0000'); 

I’ve tried searching and all I could find online were numeric formatting documents.

The reason I ask is because I think it would be an interesting idea to be able to store only the numeric values in the DB and allow for different formatting using a Constant string value to dictate how my phone numbers are formatted. Or am I better off using a number for this?

EDIT: The question is to format a string that contains numbers, not a number itself.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T19:23:12+00:00Added an answer on May 10, 2026 at 7:23 pm

    Best I can think of without having to convert to a long/number and so it fits one line is:

    string number = '1234567890'; string formattedNumber = string.Format('{0}-{1}-{2}', number.Substring(0,3), number.Substring(3,3), number.Substring(6)); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had a phone number in which the entered data should be only numeric.
I had two fields some thing like phone number and mobile number. Some thing
I had written a small utility app just for my phone, which stopped the
I am developing Android Application having ContactUs Page having Phone Number. I had given
If I had a model like this in my MVC3 application: public class Person
I had been using the following regex for US Phone Number validation, but discovered
Had a page that was working fine. Only change I made was to add
Had this working; at one stage. The problem is the following text is now
I have a UIWebView with a black background and I would like the phone
I have been had a tough time trying to figure this out. Let me

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.