I think moving the cursor each time is not really a good idea. Your program will contain a lot of logic to place the cursor at precise positions, you'll have a lot of magic numbers, and so on.
An alternative would be to simply draw your boxes, and then after each input Clear()
the console and redraw them. So your main loop would ask for a name, store it and redraw your boxes with the new input. To draw the box, simply loop on all your names (even empty ones) and Pad
them to have exactly the same length on each row.
Here is a complete example so you can see and understand the behavior (I've also hard-capped the input to 8 characters and 5 names to prevent edge cases, you can edit that quickly with the constants. And sorry for the messy StoreUserAnswer method). As you'll see, clearing the console do not flicker the screen.
namespace ConsoleApplication1
{
class Program
{
private const int MAX_NAME_LENGTH = 8;
private const int MAX_NAMES = 5;
private static string[] names = new string[MAX_NAMES];
private static int currentIndex;
static void Main(string[] args)
{
DrawBox();
while (true)
{
AskForAName();
StoreUserAnswer();
DrawBox();
}
}
private static void AskForAName()
{
Console.WriteLine("Enter a name:");
}
private static void StoreUserAnswer()
{
string name = Console.ReadLine() ?? string.Empty;
if (name.Length > MAX_NAME_LENGTH)
{
name = name.Substring(0, MAX_NAME_LENGTH);
}
names[currentIndex] = name;
currentIndex++;
if (currentIndex > MAX_NAMES - 1)
{
currentIndex = 0;
}
}
private static void DrawBox()
{
Console.Clear();
DrawDelimiter();
DrawNames();
DrawDelimiter();
}
private static void DrawDelimiter()
{
Console.WriteLine("*{0}*", new String('*', MAX_NAME_LENGTH));
}
private static void DrawNames()
{
for (int i = 0; i < MAX_NAMES; i++)
{
DrawName(names[i] ?? string.Empty);
}
}
private static void DrawName(string name)
{
Console.WriteLine("*{0}*", name.PadRight(MAX_NAME_LENGTH, ' '));
}
}
}