Created
September 10, 2019 15:23
-
-
Save marek-safar/c8757098a0269f83ee10e431f6ebc494 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
class Sample | |
{ | |
protected static int origRow; | |
protected static int origCol; | |
protected static void WriteAt(string s, int x, int y) | |
{ | |
Console.Write(" " + s); | |
Console.WriteLine (Console.CursorTop + " " + Console.CursorLeft); | |
} | |
public static void Main() | |
{ | |
// Clear the screen, then save the top and left coordinates. | |
Console.Clear(); | |
origRow = Console.CursorTop; | |
origCol = Console.CursorLeft; | |
// Draw the left side of a 5x5 rectangle, from top to bottom. | |
WriteAt("+", 0, 0); | |
WriteAt("|", 0, 1); | |
WriteAt("|", 0, 2); | |
WriteAt("|", 0, 3); | |
WriteAt("+", 0, 4); | |
// Draw the bottom side, from left to right. | |
WriteAt("-", 1, 4); // shortcut: WriteAt("---", 1, 4) | |
WriteAt("-", 2, 4); // ... | |
WriteAt("-", 3, 4); // ... | |
WriteAt("+", 4, 4); | |
// Draw the right side, from bottom to top. | |
WriteAt("|", 4, 3); | |
WriteAt("|", 4, 2); | |
WriteAt("|", 4, 1); | |
WriteAt("+", 4, 0); | |
// Draw the top side, from right to left. | |
WriteAt("-", 3, 0); // shortcut: WriteAt("---", 1, 0) | |
WriteAt("-", 2, 0); // ... | |
WriteAt("-", 1, 0); // ... | |
// | |
WriteAt("All done!", 0, 6); | |
Console.WriteLine(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment