From time to time I see code that’s been written by rookie developers. Many of them are well-intended, but their code puzzles experienced developers, because the experienced developers are used to ask themselves “is there a situation where this line of code is actually needed, like a bug in the framework?”.
The last experience I had was with the following sequence:
Random rand = new Random(); int iFirst = rand.Next( 1, 9 ); int iSecond = rand.Next( 1, 5 ); lbl1.Text = iFirst.ToString().Trim(); lbl2.Text = iSecond.ToString().Trim();
Why would anyone assume an Int32.ToString() call would insert whitespaces in the result?