Why are you using a for loop.
Just use a while(true) loop instead seeing how you are not even using the k integer value.
Edit this entire code is a mess. Since you are not asking the user to re-input a wronged variable you can simply do this:
Code
using System;
class startup
{
static string name;
static string title;
static string author;
static string isbn;
public static void Main(string[] args)
{
int k;
int errName = 0, errTitle = 0, errAuthor = 0, errISBN = 0;
while(true)
{
Console.WriteLine("Welcome! Please enter the following information to check out a book.");
ErrorMessages test = new ErrorMessages();
Console.Write("Enter your name: ");
name = Console.ReadLine();
errName = test.EmptyInput(name);
Console.Write("Enter the book's title: ");
title = Console.ReadLine();
errTitle = test.EmptyInput(title);
Console.Write("Enter the book's author: ");
author = Console.ReadLine();
errAuthor = test.EmptyInput(author);
Console.Write("Enter the book's ISBN: ");
isbn = Console.ReadLine();
errISBN = test.EmptyInput(isbn);
if(errName || errTitle || errAuthot || errISBN) {
Console.Clear();
continue;
}
Book update = new Book();
update.Display(name, title, author, isbn);
Console.Clear();
}
}
}
The only difference is that it will restart the loop after you entered in all your credentials.
I suggest you add a while loop for each input so that it will keep asking for input until it is correct:
Code
do {
name = Console.ReadLine();
} while(test.EmptyInput(name));
or something of the like.
This post was edited by AbDuCt on Mar 6 2014 04:23pm