c# - show string in a desire format -


i want show string in special format.
example have string s = "00012345"; , want show in format 000(123-45)

i use code it:

label1.text = string.format("{0,###(###-##)}",s); 

but see result: 00012345.

what string formatting should using?

as mentioned can't format existing string. first need convert string int:

int num = int32.tryparse(s); 

then can formatting whilst converting string:

label1.text = num.tostring("000(000-00)"); 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -

jdbc - Not able to establish database connection in eclipse -