Why does “hello” + + ‘/’ + “world” == “hello47world”?

The second + is converting the char to an int, and adding it into the string. The ASCII value for / is 47, which is then converted to a string by the other + operator.

The + operator before the slash implicitly casts it to an int. See + Operator on MSDN and look at the “unary plus”.

The result of a unary + operation on a numeric type is just the value of the operand.

I actually figured this out by looking at what the + operators were actually calling. (I think this is a ReSharper or VS 2015 feature)

enter image description here

enter image description here

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)