integer variable count was appended to the string even without type
casting the integer variable.
No, no integer variable was appended. The only suitable overload for the +=
operator is the one that takes a single char
parameter, and ends up adding a single character to the string. The integer value type gets converted to a char
type, and the rest is history.
So, adding 8 to the character '0'
produces, unsurprisingly, character '8'
. Things, of course, go in an exciting direction if your integer variable is negative, or greater than 9. You should try it, the results should be illuminating.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…