Is goto statement supported in C#? How about Java?
Answers were Sorted based on User's Feedback
Answer / 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 |
Can a class have more than 1 destructor?
What is a HashCode?
Difference between value and reference type.
Why objects are stored in heap in c#?
Where is the output of TextWriterTraceListener redirected?
Which collection will you use to store different types of objects collection like... int, employee, student, object etc.
how can include .netframeworl 2.0 in application setup
Difference between ByVal and ByRef?
how can i display crystal report in button_click? am working with VS2005..........plz help me
How to run the program at particular time? It should run everyday at 3:00 PM. After executing the program should sleep until next day at 3:00 PM. Please explain with code?
Why can?t you specify the accessibility modifier for methods inside the interface?
What is c# windows form application?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)