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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -