I am attempting convert this string "123456" to "12-34-56".
I try to use this code but it doesn’t seem to work correctly
string.Format("123456", "00-00-00");
Can anyone help me find a suitable pattern? Thanks for any help
>Solution :
Use below
string.Format("{0:##-##-##}", 123456);
If number is represented as string the convert to int
string.Format("{0:##-##-##}", Convert.ToInt32("123456"));
The above will print the output as
12-34-56