palovidiu,
1. I used the same number you did, and even added some numbers onto the end. It wasn't too long to convert it to a double. I didn't try for a 32 or 64 bit int or even a long or a decimal, so converting shouldn't be a problem.
2. So, if you wanted to, you could do:
Convert.ToDouble("12023023023023020302").ToString("##-##-..");. Though, this didn't exactly work the way I wanted it to.
3. If you want to break from the string.format stuff, you could do a loop and split it wherever you would like for example:
Code:
string test = "1234567890";
int CharPos=0;
StringBuilder sb = new StringBuilder();
foreach (char c in test){
CharPos++;
switch (CharPos){
case(1):case(2):case(3):
sb.Append(c);
break;
case(4):
sb.Append('-');
sb.Append(c);
break;
default:
sb.Append(c);
}
MessageBox.Show(sb.ToString());
}
OR
You could use regular expressions, and I would not be the right person to help you there...I have only a cursory knowledge of RegEx.
Of course #3 would require that you know the length of each string you want to format.
Good luck,
Kevin
- "The truth hurts, maybe not as much as jumping on a bicycle with no seat, but it hurts.