ecently, I came across an application that contained a binary + operator in which at least one of the operands
was of type string
While debugging this app, I found that the Microsoft C# compiler had compiled the the program so that the <totalNumber> value was 158, while the maximum value allowed was 100.
Why is the <totalNumber> value exceeding the maximum value allowed?
Using this small application, test your application's summing of <totalNumber> before compiling.
Recreating the Problem
Suppose you had the following logged string:
string s = a + b + c;
In the above string, a
signifies the shown text, while the integer values of b
represent the value of <totalNumber>
, after summing.
Therefore, the question you need to answer is: how is the summing being performed at run time?