Skip to content

Latest commit

 

History

History
43 lines (35 loc) · 1.54 KB

File metadata and controls

43 lines (35 loc) · 1.54 KB
title goto (C# Reference)
ms.date 07/20/2015
ms.prod .net
ms.technology
devlang-csharp
ms.topic article
f1_keywords
goto_CSharpKeyword
goto
helpviewer_keywords
goto keyword [C#]
ms.assetid 2c03c9c1-8119-44ef-b740-fb3d287a42fe
caps.latest.revision 22
author BillWagner
ms.author wiwagn

goto (C# Reference)

The goto statement transfers the program control directly to a labeled statement.

A common use of goto is to transfer control to a specific switch-case label or the default label in a switch statement.

The goto statement is also useful to get out of deeply nested loops.

Example

The following example demonstrates using goto in a switch statement.

[!code-csharpcsrefKeywordsJump#4]

Example

The following example demonstrates using goto to break out from nested loops.

[!code-csharpcsrefKeywordsJump#5]

C# Language Specification

[!INCLUDECSharplangspec]

See Also

C# Reference
C# Programming Guide
C# Keywords
goto Statement
Jump Statements