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

gcc - MinGW's ld cannot perform PE operations on non PE output file -

How to connect android app to App engine -

hadoop - Running Map Reduce Job shows error - Mkdirs failed to create /var/folders/ -