[Solved] ABOUT C# BRACKETS [closed]


This happens because of the string you have before, what you write is equivalent to :

"the sum of the numbers you entered is :" + 5 + 10;

which is the sum of a string with 2 integers, what happens when you add a number to a string is that ToString() is implicitely called in the number (making it text, it’s no longer a number) so this code is also equivalent to

"the sum of the numbers you entered is :" + "5" + "10";

If you want the numbers added you need to add them together before the implicit conversion to the string happens so you could simply put the addition of the 2 numbers between parenthesis so they’re taken into account before being added to the string (and converted to a larger string) :

"the sum of the numbers you entered is :" + (num1 + num2);

0

solved ABOUT C# BRACKETS [closed]