You how you put Console.WriteLine("Press Enter to continue");
and then you put Console.ReadLine();
Now i want it to say would you like another entry Y or N if they enter Y how do i repeat the process of going back to the excution of the program....basically how do i start it over...
I know it seems i am asking very basic question...but i started programming very differently than most developers...![]()

Repeating Sequence
elvisd
If user clicks Y how does the program repeat itself....
Clark Anderson
Check this out: http://forums.microsoft.com/msdn/ShowPost.aspx PostID=970
Anthony Dewhirst
Pieter
Try this,
do {
Console.Write("Quit (Y/N) ");
} while (Console.ReadLine().ToUpper() != "Y");
cheers,
Paul June A. Domag
Joo Lee
You are putting the do in the wrong place if you want to repeat the entire program. You need more like:
using System;
class
Strings{
static void Main(){
do {string a,b,c;
a = "Demetrius";
b = "Salena";
c = "Family";
//etc, etc
Console.Write("Quit (Y/N) ");
}
while (Console.ReadLine().ToUpper() != "Y");ScottTurner
Hi,
Ok, lets dissect the statement:
do {
// Your logic should be here...
Console.Write("Quit (Y/N) ");
} while (Console.ReadLine().ToUpper() != "Y");
the statements between do and while clauses would repeat until the expression in the while statement is true.
1. It will enter the loop, execute your logic and display "Quit (Y/N) "
2. It evaluates the while statement.
3. Since the while statement includes a call to Console.Readline() the system then waits for an input from the user.
4. After a key has been entered it is then converted to Upper Case (String.ToUpper() function)..
5. It would then compare if the letter entered is equal to 'Y'.
- if yes, then the while statement is me, and the loop terminates.
- if No, the loops executes in the beginning...
cheers,
Paul June A. Domag
Zaremba
using
System;class
Strings{
static void Main(){
string a,b,c;a = "Demetrius";
b = "Salena";
c = "Family";
Console.WriteLine("Enter Your Name");
Console.Read();
if ( a == "Demetrius")Console.WriteLine("This is Demetrius his girl is {0}", b);
else if( a != "Demetrius")Console.WriteLine("Enter another Choice");
if ( b == "Salena")Console.WriteLine("Salena boyfriend is {0}", a);
if ( c == "Family")Console.WriteLine("{0}, and {1} will start a {2}", a, b, c);
Console.WriteLine("Press Enter to continue");
Console.ReadLine();
do{
Console.Write("Quit (Y/N) ");
}
while (Console.ReadLine().ToUpper() != "Y");}
}
st3vl
Yep, you got it right...
Your input logic must be placed in the do statement so that it would be included in the loop...
cheers,
Paul June A. Domag
CodeForProject
Console.WriteLine("Enter Your Name");
Console.Read();
in the do logic so that when i enter N it goes back to these statements...what do you think
Abha Jain
The decision is in the while statement. If the user does not press a 'Y' key then the loop never ends. Just place the logic inside the while loop...
cheers,
Paul June A. Domag