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
What is private void in c#?
What are the different types of classes in c#?
What is string concatenation?
What does an indexer do?
What is javascriptserializer c#?
What is dataadapter c#?
What is the differences between datagrid, datalist and repeater in .net?
How to find whether the application is run from inside ide or not?
What is the difference between firstordefault and singleordefault?
What is reflection in c#?
Is boxing an implicit conversion?
Why delegates are type safe?
What does console mean c#?
What's the difference between the debug class and trace class? Documentation looks the same.
How big is int16?