The problem is in the MakeALine
method. You actually concat the number with itself, so for input 1
you actually get "1" + "1"
.
Instead you should repeat the string representation of your number k
times. For this you can use Enumerable.Repeat
in the following way:
static string MakeALine(int k)
{
return String.Concat(Enumerable.Repeat(k.ToString(),k));
}
3
solved How to print numbers in the following pattern with .NET