advertisement
Login | Register   
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Partners & Affiliates
advertisement
advertisement
advertisement
advertisement
Average Rating: 3.3/5 | Rate this item | 12 users have rated this item.
 

Crafting Strings in C#

When the C# compiler compiles the binary + operator with at least one operand of type string, it causes problems with your <totalNumber>. Find out how to manipulate your strings around this bug. 


advertisement
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 and c represent the value of <totalNumber>, after summing.

Therefore, the question you need to answer is: how is the summing being performed at run time?

  Next Page: Testing the Summing
Page 1: IntroductionPage 2: Testing the Summing
Please rate this item (5=best)
 1  2  3  4  5
advertisement