how to limit text to 6 numbers . 2 numbers ?
(######.##)
thank’s in advance
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use either the
String.Formatmethod or theToStringmethod:If you use
#in the formatting string, those will be filled with spaces if there are no significant digits there. For example123.456formatted using"######.##"will be" 123.46".If you use
0in the formatting string, those will be filled with zeroes of there are no significant digits there. For example123.456formatted using"000000.00"will be"000123.46".You can combine
#and0to get different results. For example you might want spaces before the decimal separator, but always at least one digit:"#####0.00".The period character is used to specify the decimal separator. This is a period for some culture settings and a comma for other. You always use the period in the format string, but the output depends on the culture settings. If you always want a period in the output you can use the
CultureInfo.InvariantCultureculture.If you don’t want the number to be rounded, you have to truncate it before formatting it: