Professional Documents
Culture Documents
Formatação de Strings para Int Com C#
Formatação de Strings para Int Com C#
[C#]
Integer numbers can be formatted in .NET in many ways. You can use static method
String.Formator instance method int.ToString. Following examples shows how to align
numbers (with spaces or zeroes), how to format negative numbers or how to do custom
formatting like phone numbers.
// "00015"
String.Format("{0:00000}", -15);
// "-00015"
// "
15"
String.Format("{0,-5}", 15);
// "15
String.Format("{0,5:000}", 15);
// "
String.Format("{0,-5:000}", 15);
// "015
"
015"
"
// "15"
// "minus 15"
// "zero"
// "89-5871-2551"