[英]Easy way to draw a Perpendicular lines on Console in C# with given Symbols
Is there any easy way or APIS to draw the boxes or line in C# on console from symbols - /,| 有什么简单的方法或APIS在控制台上从符号-/,|中绘制C#中的框或线。 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 我不确定它是否更漂亮,但是您可以使用
PadLeft
并创建一种方法来做到这一点
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 输出示例
|
|
|______
/
/
/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.