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

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

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

c# - Search and Add Comment with OpenXML for Word -