Basic doubt By a Beginner Please Help?????????
using System;
using System.Collections.Generic;
using System.Text;
namespace Accounts.home
{
class Program
{
static void Main(string[] args)
{
int a;
Console.WriteLine(" 1.Goutham Narne \n 2.Santosh Muppidi \n 3.Phani Annamarajua \n 4.Srinavasa Reddy Gaddam \n 5.Pradeep Reddy Chinthala \n 6.Satish Reddy Ala \n 7.Durgam Vamshi Krishna \n 8. Naveen Kumar Basa");
Console.WriteLine("Select the Person:-");
a=Int32.Parse(Console.ReadLine() );
if (a >= 1 || a <= 8)
{
switch (a)
{
case 1:
Console.WriteLine("Goutham Narne");
break;
case 2:
Console.WriteLine("Santosh Muppidi");
break;
case 3:
Console.WriteLine("Phani Annamaraju");
break;
case 4:
Console.WriteLine("Srinivasa Reddy Gaddam");
break;
case 5:
Console.WriteLine("Pradeep Reddy Chinthala");
break;
case 6:
Console.WriteLine("Sathish Reddy Ala");
break;
case 7:
Console.WriteLine("Durgam Vamshi Krishna");
break;
case 8:
Console.WriteLine("Naveen Kumar Basa");
break;
default:
Console.WriteLine("Invalid Option");
break;
}
}
}
}
}
//*************Please copy and paste it on ur IDE for clear understanding.
Now my doubt is how do i enter the loop and run it again for a<1 or a>8 , Please help ?????//

Vimal KandasamyRank #2,151 · 661 reputationPosted Mar 29, 2009, 8:23 PM EDT
look at below code...
i use goto loop...
in order to end loop i use a condition statement...
int a;
Console.WriteLine(" 1.Goutham Narne \n 2.Santosh Muppidi \n 3.Phani Annamarajua \n 4.Srinavasa Reddy Gaddam \n 5.Pradeep Reddy Chinthala \n 6.Satish Reddy Ala \n 7.Durgam Vamshi Krishna \n 8. Naveen Kumar Basa");
label1:
Console.WriteLine("Select the Person:-");
a=Int32.Parse(Console.ReadLine() );
if (a >= 1 || a <= 8) {
switch (a) {
case 1: Console.WriteLine("Goutham Narne"); break;
case 2: Console.WriteLine("Santosh Muppidi"); break;
case 3: Console.WriteLine("Phani Annamaraju"); break;
case 4: Console.WriteLine("Srinivasa Reddy Gaddam"); break;
case 5: Console.WriteLine("Pradeep Reddy Chinthala"); break;
case 6: Console.WriteLine("Sathish Reddy Ala"); break;
case 7: Console.WriteLine("Durgam Vamshi Krishna"); break;
case 8: Console.WriteLine("Naveen Kumar Basa"); break;
default: Console.WriteLine("Invalid Option"); break;
} }
if(a!=000)
goto label1;
if user enter 000 as input..then loop will terminate...
Mahesh ChandRank #1 · 393.2K reputationPosted Mar 29, 2009, 6:18 AM EDT
Your code is hard to read. Please format it to make it readable.
To post a code from Visual Studio, copy it first to Word doc and then copy from word doc to these forums. It will keep your code formatted.
santosh muppidi3 reputationPosted Mar 30, 2009, 3:04 AM EDT
Thank you very much mate , I'm learning by my self and i was waiting for this solution. I appreciate ur concern.
Thanks Once Again
Posted Mar 30, 2009, 7:37 PM EDT
int a;
Console.WriteLine(" 1.Goutham Narne \n 2.Santosh Muppidi \n 3.Phani Annamarajua \n 4.Srinavasa Reddy Gaddam \n 5.Pradeep Reddy Chinthala \n 6.Satish Reddy Ala \n 7.Durgam Vamshi Krishna \n 8. Naveen Kumar Basa");
do
{
a = 0;
Console.WriteLine("Select the Person:-");
if (Int32.TryParse(Console.ReadLine(), out a)
{
if (a >= 1 || a <= 8)
{
switch (a)
{
case 1: Console.WriteLine("Goutham Narne"); break;
case 2: Console.WriteLine("Santosh Muppidi"); break;
case 3: Console.WriteLine("Phani Annamaraju"); break;
case 4: Console.WriteLine("Srinivasa Reddy Gaddam"); break;
case 5: Console.WriteLine("Pradeep Reddy Chinthala"); break;
case 6: Console.WriteLine("Sathish Reddy Ala"); break;
case 7: Console.WriteLine("Durgam Vamshi Krishna"); break;
case 8: Console.WriteLine("Naveen Kumar Basa"); break;
default: Console.WriteLine("Invalid Option"); break;
}
}
}
}
while (a != 0);
There, my finger can rest easier now :P