After printing some data(a, b, c)
a
b
c
on console screen, how to get back to the first line and print x, y, z like this
a x
b y
c z
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You will have to use explicit cursor positioning for this to work on the console, it could be something like this:
public class SomeCharPos{ private char ch; private int row, col; public SomeCharPos(char ch, int row, int col){ this.ch = ch; this.row = row; this.col = col; } public char SomeChar{ get{ return this.ch; } } public int Row{ get{ return this.row; } } public int Col{ get{ return this.col; } } } public class DemoIt{ public Dictionary thisDict = new Dictionary(); public DemoIt(){ thisDict.Add('a', new SomeCharPos('a', 1, 1)); thisDict.Add('b', new SomeCharPos('a', 2, 1)); thisDict.Add('c', new SomeCharPos('a', 3, 1)); .... thisDict.Add('x', new SomeCharPos('x', 1, 3)); thisDict.Add('y', new SomeCharPos('x', 2, 3)); thisDict.Add('z', new SomeCharPos('x', 3, 3)); } public void DrawIt(){ foreach (SomeCharPos pos in thisDict.Values){ Console.SetCursorPosition(pos.Col, pos.Row); Console.Write(pos.SomeChar); } } }Hope this helps,
Best regards,
Tom.