Is there any easy way or APIS to draw the boxes or line in C# on console from symbols - /,| and _ or -. For example I want to draw something like this :
^
|
|
|
|___________>
/
/
/
I can draw two lines but not third one with "/" to look like above figure.I need an arrow as well at the end but it is I think nearly impossible.
Below is my dirty code :
Console.WriteLine("\t\t^Z");
Console.WriteLine("\t\t|");
Console.WriteLine("\t\t|");
Console.WriteLine("\t\t|");
Console.WriteLine("\t\t|");
Console.WriteLine("\t\t|");
Console.WriteLine("\t\t X");
Console.WriteLine("\t\t -------->");
Console.WriteLine("\t /");
Console.WriteLine("\t /");
Console.WriteLine("\t /");
Console.WriteLine("\t /");
Console.WriteLine("\t /");
I'm not sure if its any prettier but you could use PadLeft
and make a method to do it
public static void MakeAxis(int lineLengths)
{
for(int i = 0; i < lineLengths - 1; i++)
Console.WriteLine("|".PadLeft(lineLengths, ' '));
Console.WriteLine("|".PadLeft(lineLengths, ' ') + new String('_', lineLengths<<1));
for(int i = lineLengths; i > 0; i--)
Console.WriteLine("/".PadLeft(i, ' '));
}
Example output
|
|
|______
/
/
/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.