I am getting strings like "123456"
, "abcdef"
, "123abc"
from another application.
I need to format the strings like "123-456","abc-def"
, "123-abc"
. The length of the strings can also vary like we can have a string of lenght 30 char. If the 3rd position is chosen then after every 3rd character a hyphen should be inserted.
ex: input "abcdxy123z" output "abc-dxy-123-z" for 3rd position.
if we choose 2nd position then output will be
"ab-cd-xy-12-3z"
I tried with String.Format("{0:####-####-####-####}", Convert.ToInt64("1234567891234567")) but if I get a alphanumeric string, it does not work.