string istanbul = "523";
Convert.ToInt32(istanbul.ToString("00"));
what does it return?
string istanbul = "523";
Convert.ToInt32(istanbul.ToString("00"));
what does it return?
This will not even compile:
string istanbul = 523
You cannot assign a number to a string variable like that. You also did not terminate the statement properly with a ;
.
C# is also case sensitive, so istanbul
and Istanbul
refer to different variables.
To answer the question:
523.ToString("00"); // This will evaluate to the string "523"
Convert.ToInt32("523"); // This will evaluate to the integer 523
Read about custom numeric formatting strings.
The "0" custom format specifier serves as a zero-placeholder symbol. If the value that is being formatted has a digit in the position where the zero appears in the format string, that digit is copied to the result string; otherwise, a zero appears in the result string. The position of the leftmost zero before the decimal point and the rightmost zero after the decimal point determines the range of digits that are always present in the result string.
The "00" specifier causes the value to be rounded to the nearest digit preceding the decimal, where rounding away from zero is always used. For example, formatting 34.5 with "00" would result in the value 35.
The "0" Custom Specifier link text