"raulavi" <ra*****@discussions.microsoft.comwrote in message
news:AE**********************************@microsof t.com...
Hi:
vs2008 c#
Having a string myvar = "*";
I need to repeat this myvar 100 times when is used at run time...
string myline = myvar + myvar+ myvar....(100 times)
What the easiest way to acomplish this.
am trying to avoid the for loop
Multiple answers and so far, all can be correct, so I thought I'd throw in
another case...
If the string or "character" is just a space (which in your example, it
showed an asterisk[*], but I'm throwing in a space just for show):
string myvar = string.Empty.PadRight(100);
- OR - a normal character (note, char is not string):
string myvar = string.Empty.PadRight(100, '*');
Personally, I would use the constructor for string that takes a character
and count (already posted by someone else, but duplicated here):
string myvar = new string('*', 100);
There ;) HTH,
Mythran