Thursday, January 31, 2008

Fill a string with repeating character (.NET)

If you want to fill a string with a character n times (e.g. 'aaaaaa') then you just have to instantiate the string and pass the character and number of times, that you want it to repeat, to the constructor.

Example:

C# : String S = new String ('a',6);

VB.NET : Dim S as String = new String ('a',6)

Thats it!