-3

Possible Duplicate:
Can I “multiply” a string (in C#)?

I want to achieve this

string a = "Hello";
Console.Write (a * 10);

I want it to print out :

Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello

I know in python I can just do

a = "hello"
print a * 10

but how do I do this in C# ?

Community
  • 1
  • 1
Ba7a7chy
  • 1,471
  • 4
  • 14
  • 29
  • There's a veritable cornucopia of ways to do that here: http://stackoverflow.com/questions/532892/can-i-multiply-a-string-in-c – Robert Harvey Jul 17 '12 at 21:35
  • 1
    Instead of editing your question title to indicate that it has been solved, please [mark one of the answers as accepted](http://meta.stackexchange.com/a/5235/135887) using the built-in user interface. If none of the existing answers actually solved the problem, please add your own answer detailing the solution, then mark *that* answer as accepted. – Charles Jul 17 '12 at 23:36

1 Answers1

4
string repeated = string.Join(" ", Enumerable.Repeat("Hello", 10));
naspinski
  • 34,020
  • 36
  • 111
  • 167