简体   繁体   中英

in Vb6 and c# how do I have multiple of a string

Is there a single command that replicates a string into multiples of that string or character. Sql has replicate which can replicate a space for instance into many:

replicate(' ', 10000) -- will make 10k spaces.  

Is there a similiar command in vb6 and c#?

In C#:

string s = new string(' ', 10000);

In VB.NET:

Dim s = New String(" ", 10000)

In VB6:

s = String$(10000, " ")

To repeat an actual string, not just one character (code is the same for C# and VB.Net) :

//Repeat "asd" 100 times
String.Join("", Enumerable.Repeat("asd", 100).ToArray())

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM