Creating a String of Repeated Characters

The easiest way to create a string of repeated characters:

String.String(Char, Int32) Constructor

Initializes a new instance of the String class to the value indicated by a specified Unicode character repeated a specified number of times.

So, to create a repeating string of “x”s 12 characters long in VB.Net:

Dim myString = New String(“x”c, 12)

[Adapted from: ]


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: