CodeGotoStatement クラス
アセンブリ: System (system.dll 内)

<SerializableAttribute> _ <ComVisibleAttribute(True)> _ <ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _ Public Class CodeGotoStatement Inherits CodeStatement
[SerializableAttribute] [ComVisibleAttribute(true)] [ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] public class CodeGotoStatement : CodeStatement
[SerializableAttribute] [ComVisibleAttribute(true)] [ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] public ref class CodeGotoStatement : public CodeStatement

CodeGotoStatement を使用して、goto ステートメントを表すことができます。これは一部の言語で、プログラムの流れを指定したラベルにリダイレクトするために使用されます。
Label プロパティは、プログラムの実行を再開する位置のラベルの名前を示します。
![]() |
---|
goto ステートメントは、すべての言語でサポートされているわけではありません。コード ジェネレータが goto ステートメントをサポートしているかどうかを調べるには、GotoStatements フラグを指定して Supports を呼び出します。 |

CodeGotoStatement と CodeLabeledStatement を使用して、プログラムのフローをリダイレクトする例を次に示します。
' Declares a type to contain the example code. Dim type1 As New CodeTypeDeclaration("Type1") ' Declares an entry point method. Dim entry1 As New CodeEntryPointMethod() type1.Members.Add(entry1) ' Adds a goto statement to continue program flow at the "JumpToLabel" label. Dim goto1 As New CodeGotoStatement("JumpToLabel") entry1.Statements.Add(goto1) ' Invokes Console.WriteLine to print "Test Output", which is skipped by the goto statement. Dim method1 As New CodeMethodInvokeExpression(New CodeTypeReferenceExpression("System.Console"), "WriteLine", New CodePrimitiveExpression("Test Output.")) entry1.Statements.Add(method1) ' Declares a label named "JumpToLabel" associated with a method to output a test string using Console.WriteLine. Dim method2 As New CodeMethodInvokeExpression(New CodeTypeReferenceExpression("System.Console"), "WriteLine", New CodePrimitiveExpression("Output from labeled statement.")) Dim label1 As New CodeLabeledStatement("JumpToLabel", New CodeExpressionStatement(method2)) entry1.Statements.Add(label1) ' A Visual Basic code generator produces the following source code for the preceeding example code: ' Public Class Type1 ' ' Public Shared Sub Main() ' GoTo JumpToLabel ' System.Console.WriteLine("Test Output") ' JumpToLabel: ' System.Console.WriteLine("Output from labeled statement.") ' End Sub ' End Class
// Declares a type to contain the example code. CodeTypeDeclaration type1 = new CodeTypeDeclaration("Type1"); // Declares an entry point method. CodeEntryPointMethod entry1 = new CodeEntryPointMethod(); type1.Members.Add( entry1 ); // Adds a goto statement to continue program flow at the "JumpToLabel" label. CodeGotoStatement goto1 = new CodeGotoStatement("JumpToLabel"); entry1.Statements.Add( goto1 ); // Invokes Console.WriteLine to print "Test Output", which is skipped by the goto statement. CodeMethodInvokeExpression method1 = new CodeMethodInvokeExpression( new CodeTypeReferenceExpression("System.Console"), "WriteLine", new CodePrimitiveExpression("Test Output.")); entry1.Statements.Add( method1 ); // Declares a label named "JumpToLabel" associated with a method to output a test string using Console.WriteLine. CodeMethodInvokeExpression method2 = new CodeMethodInvokeExpression( new CodeTypeReferenceExpression("System.Console"), "WriteLine", new CodePrimitiveExpression("Output from labeled statement.")); CodeLabeledStatement label1 = new CodeLabeledStatement("JumpToLabel", new CodeExpressionStatement(method2) ); entry1.Statements.Add( label1 ); // A C# code generator produces the following source code for the preceeding example code: // public class Type1 // { // // public static void Main() // { // goto JumpToLabel; // System.Console.WriteLine("Test Output"); // JumpToLabel: // System.Console.WriteLine("Output from labeled statement."); // } // }
// Declares a type to contain the example code. CodeTypeDeclaration^ type1 = gcnew CodeTypeDeclaration( "Type1" ); // Declares an entry point method. CodeEntryPointMethod^ entry1 = gcnew CodeEntryPointMethod; type1->Members->Add( entry1 ); // Adds a goto statement to continue program flow at the "JumpToLabel" label. CodeGotoStatement^ goto1 = gcnew CodeGotoStatement( "JumpToLabel" ); entry1->Statements->Add( goto1 ); // Invokes Console.WriteLine to print "Test Output", which is skipped by the goto statement. array<CodeExpression^>^temp = {gcnew CodePrimitiveExpression( "Test Output." )}; CodeMethodInvokeExpression^ method1 = gcnew CodeMethodInvokeExpression( gcnew CodeTypeReferenceExpression( "System.Console" ),"WriteLine",temp ); entry1->Statements->Add( method1 ); // Declares a label named "JumpToLabel" associated with a method to output a test string using Console.WriteLine. array<CodeExpression^>^temp2 = {gcnew CodePrimitiveExpression( "Output from labeled statement." )}; CodeMethodInvokeExpression^ method2 = gcnew CodeMethodInvokeExpression( gcnew CodeTypeReferenceExpression( "System.Console" ),"WriteLine",temp2 ); CodeLabeledStatement^ label1 = gcnew CodeLabeledStatement( "JumpToLabel",gcnew CodeExpressionStatement( method2 ) ); entry1->Statements->Add( label1 ); // A C# code generator produces the following source code for the preceeding example code: // public class Type1 // { // // public static void Main() // { // goto JumpToLabel; // System.Console.WriteLine("Test Output"); // JumpToLabel: // System.Console.WriteLine("Output from labeled statement."); // } // }
// Declares a type to contain the example code. CodeTypeDeclaration type1 = new CodeTypeDeclaration("Type1"); // Declares an entry point method. CodeEntryPointMethod entry1 = new CodeEntryPointMethod(); type1.get_Members().Add(entry1); // Adds a goto statement to continue program flow at the // "JumpToLabel" label. CodeGotoStatement goto1 = new CodeGotoStatement("JumpToLabel"); entry1.get_Statements().Add(goto1); // Invokes Console.WriteLine to print "Test Output", which is // skipped by the goto statement. CodeMethodInvokeExpression method1 = new CodeMethodInvokeExpression (new CodeTypeReferenceExpression("System.Console"), "WriteLine", new CodePrimitiveExpression[] { new CodePrimitiveExpression("Test Output.") }); entry1.get_Statements().Add(method1); // Declares a label named "JumpToLabel" associated with a method to // output a test string using Console.WriteLine. CodeMethodInvokeExpression method2 = new CodeMethodInvokeExpression(new CodeTypeReferenceExpression( "System.Console"), "WriteLine", new CodePrimitiveExpression[] { new CodePrimitiveExpression("Output from labeled statement.") }); CodeLabeledStatement label1 = new CodeLabeledStatement("JumpToLabel", new CodeExpressionStatement(method2)); entry1.get_Statements().Add(label1); // A VJ# code generator produces the following source code for the // preceeding example code: // public class Type1 // { // public static void main() // { // goto JumpToLabel; // System.Console.WriteLine("Test Output"); // JumpToLabel: // System.Console.WriteLine("Output from labeled statement."); // } //main // } //Type1

System.CodeDom.CodeObject
System.CodeDom.CodeStatement
System.CodeDom.CodeGotoStatement


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


CodeGotoStatement コンストラクタ ()
アセンブリ: System (system.dll 内)



Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


CodeGotoStatement コンストラクタ (String)
アセンブリ: System (system.dll 内)



Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


CodeGotoStatement コンストラクタ

名前 | 説明 |
---|---|
CodeGotoStatement () | CodeGotoStatement クラスの新しいインスタンスを初期化します。 |
CodeGotoStatement (String) | ラベル名を指定して、CodeGotoStatement クラスの新しいインスタンスを初期化します。 |

CodeGotoStatement プロパティ

名前 | 説明 | |
---|---|---|
![]() | EndDirectives | 終了ディレクティブを含む CodeDirectiveCollection オブジェクトを取得します。 ( CodeStatement から継承されます。) |
![]() | Label | プログラムの実行を再開する位置のラベルの名前を取得または設定します。 |
![]() | LinePragma | コード ステートメントのある行を取得または設定します。 ( CodeStatement から継承されます。) |
![]() | StartDirectives | 開始ディレクティブを含む CodeDirectiveCollection オブジェクトを取得します。 ( CodeStatement から継承されます。) |
![]() | UserData | 現在のオブジェクトのユーザー定義可能なデータを取得または設定します。 ( CodeObject から継承されます。) |

CodeGotoStatement メソッド

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

CodeGotoStatement メンバ
CodeGotoStatement データ型で公開されるメンバを以下の表に示します。


名前 | 説明 | |
---|---|---|
![]() | EndDirectives | 終了ディレクティブを含む CodeDirectiveCollection オブジェクトを取得します。(CodeStatement から継承されます。) |
![]() | Label | プログラムの実行を再開する位置のラベルの名前を取得または設定します。 |
![]() | LinePragma | コード ステートメントのある行を取得または設定します。 (CodeStatement から継承されます。) |
![]() | StartDirectives | 開始ディレクティブを含む CodeDirectiveCollection オブジェクトを取得します。(CodeStatement から継承されます。) |
![]() | UserData | 現在のオブジェクトのユーザー定義可能なデータを取得または設定します。(CodeObject から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

- CodeGotoStatementのページへのリンク