You need to set a CursorPosition
to a given location, then need to draw a horizontal line.
Like,
public static void LineHorizontale(int x, int y, int length)
{
//This will set your cursor position on x and y
Console.SetCursorPosition(x, y);
//This will draw '-' n times here n is length
Console.WriteLine(new String('-', length));
}
if you want to print diagonal line then use \
instead of -
and increase x and y position.
something like,
public static void LineDiagonal(int x, int y, int length)
{
for(int i = 0; i < length; i++)
{
//This will set your cursor position on x and y
Console.SetCursorPosition(x+i, y+i);
//This will draw '\' n times here n is length
Console.Write(@"\");
}
}
Output:
1
solved How can I draw a diagonal line with Console.SetCursorPosition c#?