• 0

C# loop problem


Question

Hi,

Little problem with a console application in C#. I give an error message like this :

"this is not a valid credit card number". But then he still goes further in the program and asks if whom wants to donate money or not. How to QUIT the program if i have given that error message. So that the user can't go further.

OR

how to make a loop that a user can try again to fill in the correct credit card number. Only problem is, that the question "fill in you credit card number : " is in the main class1.cs, and not in the class "credit card", under the method "validation".

Help!

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Easy just do a while loop, ,and inside the while loop do a if then condition to see if the credit card number is valid, if it is, we will do whatever it's suppose to do and set the boolean value so that the while loop will end.

Link to comment
Share on other sites

  • 0

boolean validated = false;

while(validated == false)

{

if(codelogictotestifcreditcardisentered == true)

{

validated = true;

}

}

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.