Does anyone know how I might achieve something like this through Lambda expression?
public static string getString(char c, int lenght)
{
char[] temp = new char[lenght];
for (int i = 0; lenght > 0; lenght--, i++)
{
temp[i] = c;
}
return new string(temp);
}
It's a small method that I loop through:
for (int i = 0, j = width; j > 0; j--, i++)
{
item[i] = getString((char)(value + 48), j);
Console.WriteLine(item[i]);
}
To output a triangle of a number between 1 - 9.
Example:
666666
66666
6666
666
66
6
I've never used Lambda, but would like to learn it to achieve small loops like this.
If anyone knows a place full of examples, please point me in the direction.