473,383 Members | 1,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

String.Format(). How to change new?

how to change the format 9202566684 on +7(920) 256-66-84?
Sep 15 '14 #1
1 1435
Frinavale
9,735 Expert Mod 8TB
Something like this would work:
Expand|Select|Wrap|Line Numbers
  1. String original = "9202566684"
  2. String.Format("+7({0}} {1}-{2}-{3}", original.Substring(0, 2), original.Substring(3, 5), original.Substring(5, 2),original.Substring(6, 7), original.Substring(8,9));
-Frinny
Sep 16 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: raffelm | last post by:
I'm struggling to find a way to include long path names in a command line argument string that I have to build at runtime. I need to create a string like -o:"c:\my documents\my file.txt". ...
2
by: Bob | last post by:
I'm having trouble the string.Format() throwing exceptions and I can't figure out what I am doing wrong. Given the following setup code: string str = { "one", "two", "three", "four" }; double...
7
by: Alpha | last post by:
Hi, I'm maintaining C# code and am fairly new with C# programming. I'm looking for codes that's droping the 2nd digit of a nuber printed out and I suspect it's the code below. Can someone tell me...
6
by: A.M-SG | last post by:
Hi, I have the following code at the heavily demanded server side service: strResult=str1+"\\"+str2+"\\"+str3+"\\"; Would it be better (performance wise) that we change it to this: ...
6
by: java | last post by:
I am java programmer thrust into the world of c++, wasn't that competant in java to begin with so things just got harder. I have a float that comes out of a database and I want to change it (to a...
1
by: Agnes | last post by:
dim strPeriod as string = dtTransdate.ToString("dd-MMM-yyyy", System.Globalization.DateTimeFormatInfo.InvariantInfo) '--excel code ..Range("H2").Value = strPeriod When I read the excel, the...
6
by: Scewbedew | last post by:
Suppose I have the following code: string myFormat = "Line1/nLine 2"; string formattedString = string.Format(myFormat); ....that would produce a 2-line output as expected. But if I load...
8
by: Lucky | last post by:
hi guys! back again with another query. the problem is like this. i want to print a line like this: "---------------------------------------------" the easiest way is to simply assign it to...
15
by: James | last post by:
Which is better, which is faster, which is easier etc... ????? String.Format ( "yadda {0} yadda {1}", x, y ) "yadda" + x.ToString() + " yadda" + y.tostring(); My code has a mish mash of...
3
by: Frank Rizzo | last post by:
Hello, I am trying to print out an hour in a format of 3pm or 5am. I've tried the following, but it throws an exception saying invalid input string: string times =...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.