Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Is goto statement supported in C#? How about Java?

Answer Posted / ranganathkini

Yes goto is supported in C# and is not supported in Java.
They are quite handy when writing switch statements where in
moving from one case label to another. Example:

Console.Write( "Enter name of country: " );
string country = Console.ReadLine();
switch( country ) {
case "India":
Console.WriteLine( "Welcome to India" );
break;
case "USA":
Console.WriteLine( "Welcome to USA" );
break;
default:
goto case "India";
}

There also a couple of restrictions for using goto
statements in C#:

1. U cannot jump into a statement block such as a loop.
2. U cannot jump out of a class.
3. U cannot exit a finally block.

Java strongly resents the use of the goto statements and
considers it to be a bad practice for programming. In fact
some of the early Java compilers wud show a warning if the
programmer used goto in his program. The message wud be as
follows:

KeywordTest.java:4: 'goto' not supported. Duh.
You have no business programming in Java. Begin erasing Java
Software Development Kit? (Yes/No)
1 life-altering error

Tats someting i wanted to share with u guys. ;-)

Is This Answer Correct ?    2 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is Inheritance in C#?

1091


How do I trim a space in c#?

851


What is the C# syntax to catch any possible exception?

897


How to generate strong name key file or which command is used to generated strong name key file?

898


What is throw in c#?

845


What does || mean in programming?

899


What is parseexact c#?

903


What is the importance of closing an ado.net application?

848


What is the difference between proc. Sent by val and by sub?

915


Can struct have constructor c#?

862


Is inheritance possible in c sharp?

1000


How many destructors can a class have?

978


What does do in c#?

899


Does c# have its own class library?

916


Can we override interface method?

904