Strings

I went over some selenium tests today and found this code that creates a string that is used in order to test that validation is fired whenever the text entered in a text box has a greater length that allowed.

 
var temp = new StringBuilder();
for (var i = 0; i < 52; i++)
{
      temp.Append('x');
}
longerThan50Chars = temp.ToString();

 

This is all good and working code but it can all be replaced with just one line.

public static string longerThan50Chars = new string('x',52);
Print | posted on Saturday, September 04, 2010 6:21 PM

Feedback

No comments posted yet.
Title  
Name
Email (never displayed)
Url
Comments   
Please add 8 and 5 and type the answer here: