How to continue without exiting...
-
Hi guys.. I have developed a console application that migrates data present in xml file to my database.. my console application asks the app name from the user and based on the name entered by the user the application migrates only those records corresponding to that app name.. Now my question is after the migration is done my console application exits.. but i dont want it to exit, instead it must ask the user whether to exit if the user enters "exit" then it must exit otherwise the console application should repeat its migration process from the beginning and ask the user the app name and so on it goes... how do i implement this logic??? Thanx in advance.. Regards, Tash
-
Hi guys.. I have developed a console application that migrates data present in xml file to my database.. my console application asks the app name from the user and based on the name entered by the user the application migrates only those records corresponding to that app name.. Now my question is after the migration is done my console application exits.. but i dont want it to exit, instead it must ask the user whether to exit if the user enters "exit" then it must exit otherwise the console application should repeat its migration process from the beginning and ask the user the app name and so on it goes... how do i implement this logic??? Thanx in advance.. Regards, Tash
-
Hi guys.. I have developed a console application that migrates data present in xml file to my database.. my console application asks the app name from the user and based on the name entered by the user the application migrates only those records corresponding to that app name.. Now my question is after the migration is done my console application exits.. but i dont want it to exit, instead it must ask the user whether to exit if the user enters "exit" then it must exit otherwise the console application should repeat its migration process from the beginning and ask the user the app name and so on it goes... how do i implement this logic??? Thanx in advance.. Regards, Tash
Hey there Thashif I'd use a while loop for that :) Here's an example
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace ConsoleTest
{
class Program
{
static void Main(string[] args)
{
bool QuitProgram = false;while (!QuitProgram) { Console.WriteLine("Please type your name or \\"quit\\" to exit"); string Response = Console.ReadLine(); if (Response.ToLower() == "quit") { QuitProgram = true; } else { DoWork(Response); } } } public static void DoWork(string Response) { Console.WriteLine("Hello {0}", Response); } }
}
Hope this helps :)
Harvey Saayman - South Africa Software Developer .Net, C#, SQL
you.suck = (you.Occupation == jobTitles.Programmer && you.Passion != Programming)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111 -
Hey there Thashif I'd use a while loop for that :) Here's an example
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace ConsoleTest
{
class Program
{
static void Main(string[] args)
{
bool QuitProgram = false;while (!QuitProgram) { Console.WriteLine("Please type your name or \\"quit\\" to exit"); string Response = Console.ReadLine(); if (Response.ToLower() == "quit") { QuitProgram = true; } else { DoWork(Response); } } } public static void DoWork(string Response) { Console.WriteLine("Hello {0}", Response); } }
}
Hope this helps :)
Harvey Saayman - South Africa Software Developer .Net, C#, SQL
you.suck = (you.Occupation == jobTitles.Programmer && you.Passion != Programming)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111 -
bool isExit = false;
while(!isExit)
{
//ask name here...
//...//ask exit here
Console.WriteLine("Do you want to exit ?");
string answer = Console.ReadLine();
if(answer == "exit")
{
isExit = true;
}
} -
Your welcome :) PS: Please don't forget to mark the post good answer :thumbsup:
Harvey Saayman - South Africa Software Developer .Net, C#, SQL
you.suck = (you.Occupation == jobTitles.Programmer && you.Passion != Programming)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111