In Perl
print 'a' x 3; # aaa
In C#
Console.WriteLine( ??? )
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It depends what you need… there is
new string('a',3)for example.For working with strings; you could just loop… not very interesting, but it’ll work.
With 3.5, you could use
Enumerable.Repeat('a',3), but this gives you a sequence of strings, not a compound string.If you are going to use this a lot, you could use a bespoke C# 3.0 extension method: