c# - Curious about Format function with Phone Number -
update (solved): https://dotnetfiddle.net/6gejyo
i used following code format phone number in loop various formats:
string phonenumber = "9998675309" string.format("{0:" + formatstring + "}", convert.todouble(phonenumber))
i need format phone numbers 2 different ways. 1 came out expected , other did not.
so, curious, decided quick console app , see of different phone number formatting possibilities think of. here result:
my question this: why of come out formatted way seem should , others not? there escape characters needed of them?
the "."
has special meaning in format string. determines location of decimal separator in result string. have escape "."
:
string formatstring = "###-###\\.####";
some examples of usage of "."
in format strings:
// result "3.40" (3.4).tostring("#.00", cultureinfo.getcultureinfo("en-us")) // result "3,142" (3.141592).tostring("#.000", cultureinfo.getcultureinfo("nl-nl"))
Comments
Post a Comment